问题
This is a CodeChef problem for the November challenge. I donot intend to cheat. My program works well for the test input provided. But the server generates a runtime NZEC error. Can you help me identify my mistake?
T= raw_input()
for i in xrange(int(T)):
G= raw_input()
for j in xrange(int(G)):
I, N, Q = raw_input().split()
I= int(I)
N= int(N)
Q= int(Q)
a= [I]*N
print a
count=0
for k in xrange(N):
if((N-k) % 2 != 0):
if a[k]==1:
a[k]=2
else: a[k]=1
print a
for k in xrange(N):
if( a[k] == Q):
count= count+1
print count
Thank you very much.
回答1:
The problem description says that N can be 10**9
. So a= [I]*N
might require several gigabytes of memory. Your program probably terminates with MemoryError exception that leads to non-zero exit status (1
).
来源:https://stackoverflow.com/questions/13216600/why-does-my-python-program-issue-a-runtime-error-nzec-non-zero-exit-code