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

Asked

Viewed 324 times

1

I’m trying to pass a code on the SPOJ (http://br.spoj.com/problems/MITO09/) for solving a very simple problem: Read a matrix, read matrix coordinates, and check whether the same coordinate has been read twice. If yes, print 1. If not, print 0.

I am receiving error: error in Checkpoint time (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 mistake? Thank you!

  • Note that as you are inside a loop from the first that gives repeated all the others will be considered repeated, whether or not.

3 answers

1

0

I don’t know Python, but in C/C++ NZEC indicates that its main function did not return 0, that is, in C/C++ the last instruction of the main function must be Return 0;

Ex:

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

0

That’s probably the mistake import psyco. SPOJ generally doesn’t let you import libraries, with a few exceptions (sys for example). As a rule, if you had 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.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.