# Dwarfs standing on the shoulders of giants puzzle discussion

Yes There are multiple roots

Not able to pass Complex Hierarchy (Algo : BFS on every root node)

BFS but you should be able to go more than once on some nodes.

For “More complex hierarchy”, try the following (1 2)(1 3)(1 4)(3 2)(4 5) the answer should be 3, or even more complex (1 2)(1 3)(1 4)(1 5)(2 6)(2 7)(3 8)(4 8)(5 8)(7 9)(7 10)(7 11)(8 9) the answer should be 5. I managed to have a code which passed all the test cases (90%), apart from complex hierarchy. I noticed that with the examples, which I provided here, for the 1st one I got 4 instead of 3 and for the 2nd one I got 6 instead of 5. I hope that it will be helpful.

2 Likes

Are you sure, that in your second case the result is 5? Because I writed it down, and the longest path in my graph was 4 (4 is the length in this cases: 1-2-7-10,1-2-7-9, 1-2-7-11, 1-3-8-9, 1-4-8-9, 1-5-8-9). I can’t see the path, which has the length of 5…

2 Likes

Yes, you are right. It is 4 not 5. Thanks for spotting it.

Would you mind to disclose the in / out of the “more Complex Hierarchy” so we may understand why we are not passing it ?

As several users have said earlier, it may be several reasons, which are not all clearly defined in the instructions. We could deduce it from seeing the in/out.

Also to make things easier for you, you may just paste it here.

A better option would probably be to add another test to the IDE that mimics the problematic validation test case but with a different set of data

3 Likes

I had a problem with this case too and i thought its a bug but only bug here was in my code :).
“more Complex Hierarchy” is defined in test case 02 - complete example.
If you can’t reach 100% check again if your algorithm really solves this case or just passes it by the accident

I use Python 3 and my program passes all tests except “complex hierarchy”, but if the results I increase by 1 works only “complex hierarchy”. For (1,2),(2,3),(2,4),(3,4),(4,5) the result is 5

can you explin the arbitrary indexes in a deeper manner… i still dont understand my mistake…

Ok, i finally pass the “More complex hierarchy”, i forgot to merge independent chains…
try:
(1,2),(4,3),(3,1) the result is 4
(1,2),(2,3),(4,5),(5,6),(5,2) => 4
(5,6),(5,3),(6,1),(7,4),(6,2),(9,4),(4,5),(2,8) => 6

17 Likes

Thanks for these test cases. Very helpful.
I also forgot to link the smaller chains that shared a common start/end point.
Finally solved it too

Hello,

I’ve just tried with C# and I’m not able to pass the “More complex hierarchy” test.
Is this related to the bug you’ve just mention or not?

Regards,

This worked for me too. Thanks for the hint.

The last one should be added to the test cases.

Thanks, this helped me to figure out the bug in my code.

Also found your third example to be helpful. That helped me solve my code. CG staff really should add this in as an IDE test.

Have an enhancement request; can we create our own test cases? I know, you are thinking “just run this on your own computer with your own inputs. Or use jsfiddle (or other IDEs for your language of choice)”. That is a completely valid response, but I am hoping to stay within the CodinGame context.

1 Like

I have the same issue with “More complex hierarchy” test case (PHP).
My code passes all test cases in this topic and I don’t know what the issue can be.

Hi, same issue for me in C#:

• My code passes all the tests in the IDE.
• My code passes all the submission tests EXCEPT “More Complex Hierarchy”.
• My code passes all the test cases given in this forum.

I’ve tried the “Submit it twice” trick.

Of course, I am also convinced my solution is correct