Computer Science Canada [help]what' wrong with this? |
Author: | chelseafc [ Thu Jan 15, 2009 6:52 pm ] | ||
Post subject: | [help]what' wrong with this? | ||
I attended the dwite contest today and when i was doing the 4th problem, there were some test cases that didn't work. Which means there are some problems in my program. But I don't know where is wrong. Can anyone help me? What's wrong with my program?? The question is here: http://dwite.org/questions/shortest_path_around_v2.html the test cases are here(the 2nd one doesn't work in my program): http://dwite.org/home/testcase/81 My solution is here:
Although my solution is not an fast and dynamic way, let's not talk about that first. The only thing I want to know is why my program can't get the correct answer. |
Author: | DemonWasp [ Fri Jan 16, 2009 10:10 am ] |
Post subject: | RE:[help]what\' wrong with this? |
If nothing else, the last if in find() seems to be incorrect. The coordinates it tests are (x+1, y-1), but those it passes on are (x, y-1). It looks like just a copy-paste error. I'm also curious as to what the first for-loop in main() is there for, given as it executes exactly once. |
Author: | chelseafc [ Fri Jan 16, 2009 4:12 pm ] |
Post subject: | RE:[help]what\' wrong with this? |
oh,damn it ,that's the mistake... the last if is wrong!!!!What a silly mistake I had made!!!! the for loop is 5 when I submit the solution...I changed it to 1 then to see where is wrong... |
Author: | saltpro15 [ Fri Jan 16, 2009 7:15 pm ] |
Post subject: | RE:[help]what\' wrong with this? |
I think DemonWasp nailed it, because the code is otherwise correct. |