Skip to content Skip to sidebar Skip to footer

My Every Python Code Gives Nzec In Spoj

I have done a few questions in SPOJ using Python. I got a few correct. Rest all I keep on getting NZEC most of the time. I added sys.exit(0) at the end of the code. But still it sh

Solution 1:

Basically you get nzec error or runtime error when your trying to access the array greater then its size or for some testcases your program may be running infinitely...

At the last , their might be some logical error in your code , try extreme test case in your code .

Since in spoj , the site is not maintained properly, for some question i tried i got tle in python and java but got AC in C and C++. This happen bcz the setter of the problem has not set the correct timing. This type of things have happen a lot to me .

Happy coding

Solution 2:

NZEC is mostly due to array indices. Eg: A general example: string s = ''; s[0] = 'a' will give NZEC Also array indices out of bounds will give NZEC

You should try to avoid array indices as far as possible. Instead use constructs like 'for..in'

Solution 3:

Try to replace your tabulation to spaces. Also big output can cause the problem, so try use sys.stdout.write() and sys.stdout.flush(). Another often causes: reaching boundaries of list, int('423\n') or other function(argument) calling when argument is none or in bad format, calling sys.stdin.readline() after reading all input would give not handled exception, other not handled exceptions.

Post a Comment for "My Every Python Code Gives Nzec In Spoj"