Why TLE?

I am doing this problem
https://open.kattis.com/problems/quantumsuperposition
and this is my code

I am unsure why it is TLE, when the some of the user solutions are very similar to mine?
For example : envifly’s solution