Why do I get an NZEC?

faq
nzec

#61

For the python users, you can refer to this discussion http://stackoverflow.com/questions/9444503/nzec-error-in-python
Hope it helps…! :slight_smile:


#62

For python use the following link.
https://www.quora.com/How-do-I-take-input-from-STDIN-in-Python/answer/Pratiush-Prasunn


#63

Some python specific debugging NZEC:
If the issue is due to leading or trailing spaces any of the below should work for Python:-

  • input().strip().split()
  • input().strip().split(’ ')
  • raw_input().strip().split()
  • raw_input().strip().split(’ ')

If not there might be some other issue -

https://discuss.codechef.com/questions/81068/discussion-on-elaborate-list-of-reasons-for-nzec-error-in-python

https://discuss.codechef.com/questions/72153/tutorial-how-to-debug-an-nzec-error

Common exceptions are

  • LookupError (IndexError, KeyError)
  • ArithmeticError (FloatingPointError, OverflowError, ZeroDivisionError)

The last thread is not python specific but the idea is great. I faced the issue currently in python so added these for common good.


#64

I was getting same for a question in Python 2, try switching to input() and submit in Python 3. It worked for me.


#65

My code is executing fine on my laptop but give NZEC error on codechef .Please can anyone tell me what’s wrong with it.

import java.util.Scanner;

public class Main {

static int max, p;

public static void main(String[] args) {
    Scanner inp = new Scanner(System.in);
    long n = inp.nextInt();

    int A[] = new int[1000];
    int B[] = new int[1000];
    int i, j;
    int lead;



    for (i = 0; i < n; i++) {
        A* = inp.nextInt();
        B* = inp.nextInt();
    }


    for (i = 0; i < n; i++) {
        if (A* > B*) {
            lead = A* - B*;
            if (lead > max) {
                max= lead;
                p = 1;
            }
        }
        else {
            lead = B* - A*;
            if (lead > max) {
                max = lead;
                p = 2;
            }
        }
    }

    System.out.println(p+ " " + max);


}

}


#66

my code is running fine in my laptop but getting nzec in codechef . iam using java and i have used bufferedreader class and scanner class both but iam still getting nzec in both cases


#67

@codehardy can you please mention for which question you have write this code as you have created array A and B of size 1000 elements , which may be insufficient according to the constraints of the question.


#68

@doda19 can you please show the code, error must be somewhere else.


#69

link for the solution

can someone tell why i am getting NZEC error ?


#70

Hello please, I am struggling with it too

package bytelandian;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

class Bytelandian {

  Map<Long, Long> alreadyComputed = new HashMap<>();

  Long compute(Long n) {
    if (n < 12) {
      return n;
    }
    if (alreadyComputed.containsKey(n)) {
      return alreadyComputed.get(n);
    }
    Long tmp = compute(n / 2) + compute(n / 3) + compute(n / 4);
    if (tmp < n) {
      tmp = n;
    }
    alreadyComputed.put(n, tmp);
//    System.out.println(alreadyComputed + "");
    return tmp;
  }


  public static void main(String[] args) throws Exception {
    Bytelandian b1 = new Bytelandian();

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String line;
    while (!(line = br.readLine()).equals("")) {
      System.out.println(b1.compute(Long.parseLong(line)));
    }
  }
}

example submission:

https://www.codechef.com/viewsolution/17182239

it says 4468M mem, but it seems impossible to me

please help, I would like to complete challenges, but error after error occurs when I would like to check my work


#71

If you are using java then remove the package declaration to fix the NZEC error.


#72

why i am getting nzec error while i am using javascript


#73

https://www.codechef.com/viewsolution/20963272
This is solution of a question ,it is running perfectly on my laptop but giving an NZEC error on codechef.
Anyone please help.Help me in knowing my mistakes.


#74

#include<stdio.h>
void main()
{
int i,t,X,Y,Z,x,y,z;
scanf("%d
“,&t);
scanf(”%d%d%d",&X,&Y,&Z);
for(i=0;i<t;i++)
{
x=X-Y;
y=Y-Z;
z=Z-X;
if(x>y && y>z && z>x)
printf(“yes”);
else
printf(“no”);
}
}


#75

I am getting the same error as I am using python
while taking the input only


#76

Not a logic problem as I tested it on a file with all possible input values. Tried commenting out all algorithmic functions (just read input and print out 1). Still getting NZEC.


#77

Found it. It didn’t like the first line: “package MISINTER;”


#78

How do i use the map function to accept array of integers entered on the same line???


#79

this is CHEFSQ problem


#80

check for run time exceptions