You are not logged in. Please login at www.codechef.com to post your questions!

×

How to find NZEC error ??

Hi! please tell me what is NZEC error, how to find it inside the code and how to prevent it ? How do codechef encounter NZEC errors, do they use any software ??

asked 02 Feb '13, 13:52

imanshuraj's gravatar image

2★imanshuraj
1135
accept rate: 0%

edited 02 Feb '13, 14:33


can u post ur source code for which u get this NZEC error?? then its easy for us to figure out

link

answered 02 Feb '13, 14:12

hariprasath's gravatar image

2★hariprasath
2805917
accept rate: 0%

Usually, returning non-zero values from main() will cause this error. It helps telling crash from WA (Wrong Answer) with interpreted languages. Typically this would happen if you omit a return 0; from main() in C. For interpreted languages or Java/C++, this could happen if your program threw an exception which was not caught (e.g. Trying to allocate too much memory in a vector).

link

answered 02 Feb '13, 14:13

hariprasath's gravatar image

2★hariprasath
2805917
accept rate: 0%

actually i use to code in python where there is no such use of return 0 statement. I have submitted many problems in Python.

(02 Feb '13, 14:28) imanshuraj2★
1

Then its due to some exception trace your source code carefully

(02 Feb '13, 18:55) hariprasath2★

I am new to python and programming after all.... The program runs correctly but gives NZEC error during submission plz check this code.. Its the solution to first question in Code Chef >> Practice>> Easy

n = long(raw_input('N = ')) m = long(raw_input('M = ')) k = long(raw_input('K = '))

print n #####used for testing puposes

print m

print k

dict1 = {} arr = [] arrc = [] ctr = 0

for i in range(n): temp = raw_input("element %d: " %i) temp = int(temp) arr.append(temp)

print arr ############ these are used for testing can be omitted

for i in range(n-1): arrc = arr[:] sums = 0 for j in range(i+1,n): while(arrc[i] <= m and arrc[j] <= m): arrc[i]+=k arrc[j]+=k for j in range(n): sums+=arrc[j]

# print arrc ######### these too # print sums ######### ---do----

dict1[sums] = sums

print dict1 #for testing purposes

ctr = (dict1.sizeof()/124) % 1000000007

print "Ans= ",ctr

link

answered 26 Sep '13, 21:10

paru05's gravatar image

0★paru05
1
accept rate: 0%

my code is

import java.io.; import java.lang.; public class sum { public static void main (String[] args)throws Exception { java.io.BufferedReader r = new java.io.BufferedReader (new java.io.InputStreamReader (System.in)); System.out.println("Enter the number"); int i=Integer.parseInt(r.readLine()); int sum=0; for(int j=1;j<i;j++) { if(i%j==0) { sum+=j; } } System.out.println(sum); } }

http://www.codechef.com/submit/DS10

(22 May '14, 21:02) harsh591★

How can I remove NZEC error from the following code:-

import java.util.Scanner;

class holes {

public static void main(String args[]){

int holes=0;
int[] z=new int[100];
Scanner a=new Scanner(System.in);
Scanner b=new Scanner(System.in);

int n=a.nextInt();
for(int i=0;i<n;i++)
{

    String x=b.nextLine();
    for(int j=0;j<x.length();j++)
    {
        if(x.charAt(j)=='A'||x.charAt(j)=='D'||x.charAt(j)=='O'||x.charAt(j)=='P'||x.charAt(j)=='Q'||x.charAt(j)=='R')
        {
            holes++;
        }
        else if(x.charAt(j)=='B')
        {
            holes+=2;
        }   
    }
    z[i]=holes;
    holes=0;

}

for(int i=0;i<n;i++) System.out.println(z[i]); } }

link

answered 02 Jul '14, 21:30

sayrandhri's gravatar image

0★sayrandhri
1
accept rate: 0%

If n>100 in your code , it will give you NZEC error

(01 Sep '16, 00:57) yb4singh4★

you can declare your array z dynamically or declare it with max value of n

(01 Sep '16, 00:57) yb4singh4★

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner;

/ * @author Alpesh prajapati / public class holes { public static void main(String argss[]) throws IOException { int i; BufferedReader bf=new BufferedReader(new InputStreamReader(System.in)); Scanner sc=new Scanner(System.in); int n=sc.nextInt(); String[] s=new String[n]; int[] p=new int[n]; for(i=0;i<n;i++){ p[i]=0; s[i]=bf.readLine(); for(int j=0;j<s[i].length();j++) { if(s[i].charAt(j)=='A' || s[i].charAt(j)=='D' || s[i].charAt(j)=='O' || s[i].charAt(j)=='P' || s[i].charAt(j)=='R' ||s[i].charAt(j)=='Q') {p[i]++;j++;} else if(s[i].charAt(j)=='B') {p[i]=p[i]+2;j++;} } } for(i=0;i<n;i++) { System.out.println(p[i]); } } } Gettingg NZEC ERROR help me out

link

answered 21 Sep '14, 22:10

kapil0411's gravatar image

0★kapil0411
1
accept rate: 0%

i am getting nzec again and again

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner;

public class ChefPoetry { static BufferedReader br; static Scanner sc;

public static void main(String[] args) throws NumberFormatException,
        IOException {
    sc= new Scanner(System.in);

    br = new BufferedReader(new InputStreamReader(System.in));
    int t = Integer.parseInt(br.readLine());
    for (int i = 0; i < t; i++) {
        check();

    }

}

private static void check() throws IOException {
    // TODO Auto-generated method stub
    int x, y, k, n;
    int p, c;
    boolean flag = false;
    String line = sc.nextLine();
    String token[] = line.split(" ");

    x = Integer.parseInt(token[0]);

    y = Integer.parseInt(token[1]);

    k = Integer.parseInt(token[2]);

    n = Integer.parseInt(token[3]);

    if (x >= 1 && x <= 1000 && y >= 1 && y <= 1000 && k >= 1 && k <= 1000
            && n >= 1 && n <= 100000) {

        for (int j = 0; j < n; j++) {
            String line2 = br.readLine();
            String token2[] = line2.split(" ");
            p = Integer.parseInt(token2[0]);
            c = Integer.parseInt(token2[1]);
            if (p >= 1 && p <= 1000 && c >= 1 && c <= 1000) {

                if (x <= y + p && k >= c) {
                    flag = true;
                    break;
                }

            } else {
                System.exit(2);

            }

        }
        if (flag)
            System.out.println("LuckyChef");

        else
            System.out.println("UnluckyChef");

    } else {System.exit(2);}


}

}

link

answered 13 Mar '15, 17:33

shibli786's gravatar image

2★shibli786
723
accept rate: 7%

How to remove my NZEC error from this code? import java.text.DecimalFormat; import java.io.*; class ATM { public static void main(String args[])throws IOException {

       BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      DecimalFormat four = new DecimalFormat("#0.00");
       int a=Integer.parseInt(br.readLine());
       double b=Double.parseDouble(br.readLine());
       double c=0.00;
       if(a>b)
       {

       System.out.println(four.format(b));
       System.exit(0);
    }
       if(a==b)
       {
           System.out.println(four.format(0));
           System.exit(0);
        }
       if(a%5==0)
       {
           c=b-a-.50;
        System.out.print(four.format(c));

    }
    else {
        System.out.print(four.format(b));;
    }
    }
}
link

answered 23 Jun '15, 01:55

javisth's gravatar image

2★javisth
1
accept rate: 0%

Can anybody help with NZEC in question FIRESC http://www.codechef.com/problems/FIRESC/ .

Here is my solution http://www.codechef.com/viewsolution/7268210

link

answered 23 Jun '15, 13:25

ankurverma1994's gravatar image

4★ankurverma1994
405114
accept rate: 8%

Runtime Error(NZEC) t=int(input()) a=[] b=[] c=[] if t>=1 and t<=1000 : for i in range(t): a.append(int(input())) b.append(int(input())) if a[i]>=1 and a[i]<=10000 and b[i]>=1 and b[i]<=10000 : c.append(a[i]+b[i]) for i in range(t): print(c[i]) How can I solve this in codechef ?

link

answered 06 Jan '16, 10:59

suryansh009's gravatar image

0★suryansh009
1
accept rate: 0%

can anyone tell me about the runtime error caused in my written code----

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

link

answered 24 Feb '16, 02:20

adicodechef_02's gravatar image

2★adicodechef_02
1
accept rate: 0%

But it is not showing any runtime error! What are you talking about? See- https://ideone.com/mxx7KI

(24 Feb '16, 02:58) debjitdj4★

Can Anyone tell me about my NZEC error? My code is..

#include<stdio.h>
/*gcc C,Turbo C*/
float main()
{
int x,y=120;
float r;
scanf("%d",&x);
if (x%5!=0)
{
printf("Incorrect widrwal");
}
else if (x>y)
{
printf("Insufficient Funds");
}
else if(x%5==0)
{
r=(120-x)-0.50;
printf("Puja's account balance is %f",r);
}
return 0;
}
link

answered 03 Aug '16, 17:58

joker_007coder's gravatar image

0★joker_007coder
1
accept rate: 0%

I am getting this error. I have tried this code for many sample input. However, it is showing NZEC error when i try submitting the code.

MY CODE :

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

link

answered 01 Sep '16, 00:09

pratyk's gravatar image

2★pratyk
1
accept rate: 0%

I am also having the same problem of nzec in following program. import java.util.*;

class Solution { static long want = 0, red = 0; static int i = 0;

static long[] a= new long[(int)10000];
static long[] b= new long[(int)10000];

static void marks(long e,long n) {

    Scanner S = new Scanner(System.in);

    if( n == 1) {
        while( e > 1 ) {
        long sum = S.nextLong();
        a[i] = a[i] + sum;
        e--;
        }
    }
    else {
        while( e > 0 ) {
        long sum = S.nextLong();
        a[i] = a[i] + sum;
        e--;
        }
    }
    i++;


}

static void sort() {
    long temp = 0;

    for ( int j = 0 ; j < i ; j++ ) {
        for( int k = j+1 ; k < i ; k++ ) {
            if( a[j] < a[k] ) {

                temp = a[k];
                a[k] =a[j];
                a[j] = temp;

            }
        }
    }

}

static void select(int k) {

    int z = 0;
    while ( k > 0 ) {
        b[z] = a[k-1];
        z++;
        k--;
    }

}

static long min(long k) {

    if ( red > b[0] )
        want = 0;
    else if ( red == b[0] )
        want = 1;
    else
        want = b[0] - red + 1;
    return want;


}

public static void main(String[] args) {

    Scanner S = new Scanner(System.in);

    long t = S.nextLong();


    while(t>0) {

        for ( int l = 0 ; l < a.length ; l++ ){
            a[l] = 0;
            b[l] = 0; 
        }
        i = 0;
        want  = 0;
        red = 0;

        long n = S.nextLong();
        if( n < 1 || n > 10000 )
            System.exit(0);

        int k = S.nextInt();
        if( n < 1 || n > 10000 )
            System.exit(0);

        long e = S.nextLong();
        if( e < 1 || e > 4 )
            System.exit(0);

        long m = S.nextLong();
        if( m < 1 || m > 1000000000 )
            System.exit(0);

        while( n > 0) {
            marks(e,n);
            n--;
        }
        red = a[i-1];
        sort();
        select(k);
        long ans = min(k);
        System.out.println(""+ans);
        t--;
    }

}

}

link

answered 06 Oct '16, 00:08

jainmohit105's gravatar image

2★jainmohit105
1
accept rate: 0%

I am facing NZEC runtime error in this code.. what wrong am i doing??

t=int(raw_input()) while(t>0): c=int(input()) d=int(input()) l=int(input()) if l%4==0: l1=l/4 if l1<= c+d: if c<=2d and l1>=d: print "yes\n" elif c>2d and l1>= c+d-2*d: print "yes\n" else: print "no\n" else: print "no\n" else: print "no\n" t-=1

link

answered 24 Jan '17, 18:13

ojasagarwal97's gravatar image

3★ojasagarwal97
1
accept rate: 0%

@adicodechef

I highly suspect that the error is due to missing return statement and "main()"

Change it to "int main()" and add a "return 0;" in end of program.

link

answered 24 Jan '17, 21:24

vijju123's gravatar image

5★vijju123 ♦♦
15.1k11857
accept rate: 18%

Plz Help me I Am Getting Same Error

Code Here-

/ package codechef; // don't place package name! /

import java.util.; import java.lang.; import java.io.*;

/ Name of the class has to be "Main" only if the class is public. / class Codechef { public static void main (String[] args) throws java.lang.Exception { BufferedReader p = new BufferedReader(new InputStreamReader(System.in));

    int queries= Integer.parseInt(p.readLine());
    int big,small;
    for (int i =0;i<=queries;i++)
    {

        int a= Integer.parseInt(p.readLine());
         int b= Integer.parseInt(p.readLine());
         if(a>b)
         {
       big=a;
         small=b;
      }
      else
      {
        big=b;
         small=a;  
      }


         if(a%2!=0 && b%2!=0)
         {
             if(a+2==b || a-2==b)
             System.out.println("Yes");
         }
         else if (a%2==0 && b%2==0)
         {
             if(a+2==b || a-2==b)
             System.out.println("Yes");
         }

         else if (big-small==1 && big%2==0)
         System.out.println("Yes");

         else
         System.out.println("No");



    }

} }

link

answered 02 Apr '17, 13:59

zaidisameer02's gravatar image

0★zaidisameer02
1
accept rate: 0%

def home():

x=[]

for number in range(0,4):

value = int(input('Enter the values for %dth element'%number))
x.append(value)

if x[2] - x[0] > 0 and x[1] - x[3] == 0:

print ('right')

elif x[0] - x[2] > 0 and x[1] - x[3] == 0:

print('left')

elif x[0]-x[2] == 0 and x[1] - x[3] > 0 :

print ('down')

elif x[0] - x[2] == 0 and x[1] - x[3] > 0 :

print ('up')

else : print ('sad')

test_case= int(input('Enter the number of test cases')) for no in range(0,test_case): home()

I'm getting NZEC for this code. Someone help me out!

link

answered 09 Apr '17, 02:36

themitigater's gravatar image

3★themitigater
11
accept rate: 0%

edited 09 Apr '17, 02:39

How remove NZEC / package codechef; // don't place package name! /

import java.util.; import java.lang.; import java.io.*;

/ Name of the class has to be "Main" only if the class is public. / class Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner sc=new Scanner(System.in); int x=sc.nextInt(); int y=sc.nextInt(); if (y>x) { double b=(y-x)-0.50; System.out.println(b);

    }
    else System.out.println(y);


    sc.close();  
}

}

link

answered 03 Jul '17, 18:59

gourav_15's gravatar image

0★gourav_15
1
accept rate: 0%

why does the following code give NZEC error ? T = input() N = [0 for i in range (0,T)] P = [0 for i in range(T)] res = ["no" for i in range(T)] p = [0 for i in range(500)] cc = [0 for i in range(500)] ch = [0 for i in range(500)] for i in range(0,T): N[i] = input() P[i] = input() for j in range (0, N[i]): p[j] = input() if (p[j]>=(P[i]/2)): cc[i] = cc[i]+1 elif (p[j]<=(P[i]/10)): ch[i] = ch[i]+1 if((cc[i] == 1) and (ch[i] == 2)): res[i] = "yes" for i in range(0,T): print res[i]

link

answered 01 Nov '17, 19:21

sleeping_123's gravatar image

4★sleeping_123
1
accept rate: 0%

Solution -> Why does this code gives NZEC??

Thank You

link

answered 22 Feb, 00:54

yjs9398's gravatar image

4★yjs9398
1
accept rate: 0%

Due to brute force consuming lot of memory in recursion calls and overflowing the memory stack. Use map data structure and memoization.

(22 Feb, 01:19) vijju123 ♦♦5★

Thank you so much, i tried the memoization and got an AC.

(26 Feb, 19:27) yjs93984★

adding an exception handler which does nothing removes the nzec error

java example:

try { } catch (Exception e){}

link
This answer is marked "community wiki".

answered 26 Feb, 22:36

manav_44's gravatar image

2★manav_44
1
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×408

question asked: 02 Feb '13, 13:52

question was seen: 24,725 times

last updated: 26 Feb, 22:36