Can't find mistake in C++ code for beautiful graph

This question beautiful graph, i solved it using Java, in C++ i can’t figure out what is the issue. i get into infinite loop. Same solution in Java got AC. please help me out. Here is the link for my solution:
https://ide.geeksforgeeks.org/2tZ8Zhcb4N

Answer to the given test case:
0
3
4
0
6
8
0
16
296595689
0
0
80

Hey @jigyansu
You forgot to input t

Hi Kartik. Thanks for pointing the error. But still taking t input and precalculating powers of 2, i get TLE for test case 22 on codeforces for this question. Here is the updated solution
https://ide.geeksforgeeks.org/pme7qGNS2x

Hey @jigyansu
Everything else looks correct to me so constraints might be tight
Try avoiding extra computation like function calls to power
Also create col and graph locally as pass as function args so u dont have to clear it for each test case.
These things might help :slight_smile:

your advice worked AC. Thank you very much

1 Like

Please mark this as resolved :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.