When submitting a solution in C++, please select either C++14 (GCC 6-32) or C++17 (GCC 7-32) as your compiler. ×

bskfred's blog

By bskfred, history, 6 years ago, In English

Hello!

What's wrong with that code?

https://github.com/fredryco/Grafos/blob/master/Trabalhos/src/Museum.java

https://github.com/fredryco/Grafos/blob/master/Trabalhos/src/Questao4.java

I know the class name must by Main, i switch when submit this, but i got this message "Runtime error on test 1"

Someone can help me

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

It's actually full of bugs. You always reinitalize your sc variable. You should call new Scanner(System.in) only once, at the beginning of the program. Also sc.nextLine() reads an empty line for the first time, because after reading 3 ints from the first line, the scanner didn't go past the first '\n', so you have to call an sc.nextLine() before the for loop, after reading the 3 ints. In the dfs function there is overindexing, because you don't check for both variable's limits.

If you go into your submission, you can see details of your runtime error, the judge gives even the line of the error, and the type of it also, by googling it, you can find out the error yourself.