Recalling Early Days GP with Trees

  • + 0 comments

    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