Why does my Python program issue a runtime error- NZEC( Non-zero exit code)?

感情迁移 提交于 2019-12-25 01:06:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!