Python - NZEC problem in SPOJ (br.spoj.com)

1

I'm trying to pass a code in SPOJ ( link ) to solve a very simple problem: Read an array, read matrix coordinates, and verify that the same coordinate has been read twice. If yes, print 1. If not, print 0.

I'm getting the error: Run-time error (NZEC).

The code:

import sys
import psyco
psyco.full()

def main():
    matriz = [[]]
    i = 0
    j = 0
    repetido = False
    x = 0
    y = 0
    n = 0

    #sys.stdin.readline()
    for i in range(530):
        for j in range(530):
            matriz[i].append(0)
        matriz.append([])
    del matriz[530]

    n = int(raw_input())
    for i in range(n):
        gamb = raw_input().split();
        x = int(gamb[0])
        y = int(gamb[1])
        if matriz[x][y] == 1:
            repetido = True
        else:
            matriz[x][y] = 1

    if repetido:
        print "1"
    else:
        print "0"

main()

What could cause this kind of error? Thanks!

    
asked by anonymous 25.03.2014 / 16:37

3 answers

1

This happens when you attempt to access an invalid position if there are syntax errors in type conversion or something similar.

The most common mistakes follow:

25.03.2014 / 17:09
0

The error is probably this import psyco . SPOJ generally does not let you import libraries, with a few exceptions (% with% for example). As a general rule, if you needed to download the library separately, do not use.

The good news is that the library is not being used for anything in your code. You can delete lines 2 and 3 and nothing will happen.

    
29.04.2014 / 13:13
0

I do not know Python, but in C / C ++ NZEC indicates that its main function did not return 0, that is, in C / C ++ the last statement of the main function should be return 0;

Ex:

#include<stdio.h>
int main() {
  // Código
  return 0; //Solução para NZEC
}
    
10.05.2014 / 16:38