Sequence Land - INOI Practice

I have been trying this problem and ended up with RE. can’t get where the problem which causes RE lies??? Any help would be greatly appreciated. Thanks in advance.

Here my graph is numbers, of which each cell has number of id’s both have in common,and run a dfs with president as a starting node and find out how many relatives that the president has.

Can’t get why RE exists. Thanks in advance!!!

Here lies the problem.
Here is my code :
That matrix shows the graph built in O(N**3).

Correct me if I’m doing wrong.

The question stated is incorrect when i looked for the original question it stated that the Each number in each id is between 0 and 10^9 inclusive instead of 109 that’s why RE is coming

1 Like

Thank you deepak…Tried and so many RE’s…Banging my head and can’t find any good reason why it is RE…!!!