Why is this code getting SIGSEGV (RTE) in all the test cases. (START72A XOR Tree)

I know this seems lazy but I have been at this for over an hour and still can’t figure it out.
Thanks.
My Submission.

I am sad to hear that it took you an hour, but these should have been avoidable.
If you always turn on -Wall in the compile options, you will get the following warning.

58:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }

So just set the int acolyte(int i, int parent) into void acolyte(int i, int parent).

Then the RTE issue was then resolved (but returned WA lol)

https://www.codechef.com/viewsolution/84545640

This is the set of data that makes your code WA.

1
3
3 3 2 
1 2
2 3

The correct answer is 1, you output 0. I hope my answer is useful to you.

The last few TLs may indicate that the combination of map and trie is too slow to pass this question, Perhaps you need to optimise your algorithm again.

1 Like

Yes, the map is heavy and redundant.
Need to rewrite the code without it.