Runtime error(NZEC) in XOR GAME using python

when i was trying to solve XOR Game i was able to pass the given testcase and when i submit it i was getting runtime error…please help me to know the reason behind it.
https://www.codechef.com/viewsolution/29785060

Runtime error is an error that occurs during the execution of a program. In contrast, compile-time errors occur while a program is being compiled. Runtime errors indicate bugs in the program or problems that the designers had anticipated but could do nothing about. For example, running out of memory will often cause a runtime error.
And you probably know that python requires more memory compared with other.
You can solve the problem using C++ and if you want to solve it with python than stop using some fact like using nested loop or using too much list or using any module.

1 Like

The number of elemens of your variable “count” should be larger. Just change your line

count=[0]*100000

for this one:

count=[0]*1000001

1 Like

thank you,but as per the question the size of n is 10pow5…so why do we need to take 10pow6+1?

You are counting the values of B, that can be as large as 10^6. As the list is 0-indexed you need 10^6 +1 elements

1 Like

yeah…i didnt see that,thanks again

1 Like