We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Recalling Early Days GP with Trees
Recalling Early Days GP with Trees
Sort by
recency
|
8 Discussions
|
Please Login in order to post a comment
why my code runs fast locally but always timeout when submited? for example it consumes less than 1 second for test case 10 in my machine.
C++ solution
File "linkedList.py", line 32, in find_path
newpath = find_path(graph, node, end, path)
File "linkedList.py", line 26, in find_path
if start == end:
RecursionError: maximum recursion depth exceeded in comparison
cat: write error: Broken pipe
how to overcome this issue. I am using recursion to find path between i and j. i can increase max recursion depth by using sys.setrecursionlimit(limit). But it will also not going to work (timeout issue)
I wrote a solution, and for the sample input and TestCase 1 it goes fine, but the output is completely different for TestCase 0.
I even made it by hand and wasn't able to find how could I achieve the expected output.
Made the program print step by step of the execution, and all paths and calculation seems to be exactly how the problem asked:
Test case 0 output:
Updating
-> 5 - 7
-> 4 - 14
-> 8 - 28
-> 9 - 56
-> 6 - 112
-> 3 - 224
-> 7 - 448
-> 10 - 896
Updating
-> 5 - 2
-> 4 - 4
-> 8 - 8
-> 9 - 16
-> 6 - 32
-> 3 - 64
-> 2 - 128
Updating
-> 8 - 9
-> 9 - 18
-> 6 - 36
-> 3 - 72
-> 7 - 144
-> 10 - 288
Updating
-> 1 - 8
-> 6 - 16
-> 3 - 32
-> 7 - 64
-> 10 - 128
Updating
-> 8 - 10
-> 9 - 20
-> 6 - 40
-> 3 - 80
-> 2 - 160
Updating
-> 5 - 3
-> 4 - 6
-> 8 - 12
-> 9 - 24
-> 6 - 48
Updating
-> 1 - 1
-> 6 - 2
-> 3 - 4
-> 2 - 8
Updating
-> 5 - 3
-> 4 - 6
-> 8 - 12
-> 9 - 24
Updating
-> 3 - 4
-> 7 - 8
-> 10 - 16
Updating
-> 8 - 8
-> 9 - 16
-> 6 - 32
Summing values
-> 7 - 8
-> 10 - 16
24
Summing values
-> 3 - 4
-> 2 - 8
12
Summing values
-> 1 - 1
-> 6 - 32
33
Summing values
-> 8 - 8
-> 9 - 16
24
Summing values
-> 5 - 3
-> 4 - 6
9
Summing values
-> 5 - 3
-> 4 - 6
-> 8 - 8
-> 9 - 16
-> 6 - 32
-> 3 - 4
-> 7 - 8
-> 10 - 16
93
Summing values
-> 5 - 3
-> 4 - 6
-> 8 - 8
-> 9 - 16
-> 6 - 32
-> 3 - 4
-> 2 - 8
77
Summing values
-> 8 - 8
-> 9 - 16
-> 6 - 32
-> 3 - 4
-> 7 - 8
-> 10 - 16
84
Summing values
-> 1 - 1
-> 6 - 32
-> 3 - 4
-> 7 - 8
-> 10 - 16
61
Summing values
-> 8 - 8
-> 9 - 16
-> 6 - 32
-> 3 - 4
-> 2 - 8
68