Results 1 to 5 of 5
  1. #1
    karthikccet is offline karthikccet
    Join Date
    Oct 2011
    Posts
    3
    Rep Power
    0

    Default NZEC runtime error in java

    can any one help me to know what is this NZEC runtime error in java... this happens when i try to upload a java program that calculates number of possible substrings in a string which occurs most number of times.. to online judge. my output is correct as per their output...but shows runtime error...this is my program


    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.util.Scanner;
    public class Main{
    public static void main(String args[]) throws IOException{
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    short j,count=0,k,count1=0,count2=0,strln=0,h;
    short i=0,a,b,c;
    short[] mk=new short[30];
    String[] atr=new String[15];
    String str1="";
    String str11="";
    String str111="";
    for(k=0;k<15;k++)
    atr[k]=new String();
    while((i!=15)?true:false)
    {
    str1=br.readLine();
    h=(short)str1.indexOf(" ");
    a=Short.parseShort(str1.substring(0, h));
    b=Short.parseShort(str1.substring(h+1));
    if(a==0&&b==0)
    break;
    atr[i]=br.readLine();
    mk[i*2]=a;
    mk[(i*2)+1]=b;
    i++;
    }
    for(j=0;j<i;j++)
    {
    for(a=mk[j*2];a<=mk[(j*2)+1];a++)
    {
    for(b=0;b+a<=atr[j].length();b++)
    {
    str11=atr[j].substring(b,b+a);
    for(c=0;c+a<=atr[j].length();c++)
    {
    str111=atr[j].substring(c,c+a);
    if(str11.equals(str111))
    {
    count++;
    }
    }
    if(count1<count)
    {
    count1=count;
    count=0;
    }
    count=0;
    }
    if(count2<count1)
    {
    count2=count1;
    count1=0;
    strln= (short) str11.length();
    }
    if(count2==count1)
    {
    strln= (short) str11.length();
    }
    count1=0;
    }
    System.out.println("" + count2 + " " + strln);
    count2=0;
    strln=0;
    }
    }
    }

  2. #2
    Solarsonic is offline Senior Member
    Join Date
    Mar 2011
    Posts
    261
    Rep Power
    4

    Default Re: NZEC runtime error in java

    You're not catching any exceptions here. Add some exception handling and a couple println() statements to find out what's causing it.

  3. #3
    karthikccet is offline karthikccet
    Join Date
    Oct 2011
    Posts
    3
    Rep Power
    0

    Default Re: NZEC runtime error in java

    Quote Originally Posted by Solarsonic View Post
    You're not catching any exceptions here. Add some exception handling and a couple println() statements to find out what's causing it.
    but it runs when i give all possible inputs, it shows runtime error while submitting only, even if i write catch statements it will not cause exception for me , then how can i find out...? please help me. error is nzec error. when i search in net for this error it shows it occurs due to accessing array elements with bad index

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: NZEC runtime error in java

    1) what are you trying to input to the program?
    2) what is the program supposed to be doing with the input?
    3) I agree that you should sprinkle printlns throughout the program -- especially near where the error occurs -- to know the state of your program when the error occurs.

  5. #5
    karthikccet is offline karthikccet
    Join Date
    Oct 2011
    Posts
    3
    Rep Power
    0

    Default Re: NZEC runtime error in java

    Quote Originally Posted by Fubarable View Post
    1) what are you trying to input to the program?
    2) what is the program supposed to be doing with the input?
    3) I agree that you should sprinkle printlns throughout the program -- especially near where the error occurs -- to know the state of your program when the error occurs.
    Repeated String
    Given a string S (containing at most 10^5 lowercase English letters). You are requested to find out from continuous substrings a string having length from L to H, which appears the most times; if there are more than one answer, find the most length.
    Input

    There are several test cases (fifteen at most), each formed as follows:

    * The first line contains two positive integers L, H.
    * The second line contains the string S.

    The input is ended with L = H = 0.
    Output

    For each test case, output on a line two integers which are the number of times appearing and the length of the found string, respectively.
    Example

    Input:
    3 5
    aabcbcbca
    3 5
    baaaababababbababbab
    1 4
    abcd
    0 0


    Output:
    2 4
    6 3
    1 4

    Explanation
    Case #1: bcbc occurs twice - at position 3 and position 5 (occurrences may overlap).
    Case #2: bab occurs 6 times.
    Case #3: abcd occurs 1 time. this is the question

Similar Threads

  1. Replies: 1
    Last Post: 07-05-2011, 03:27 AM
  2. Java Runtime Error! :(
    By RoadRunner in forum New To Java
    Replies: 6
    Last Post: 01-20-2011, 04:58 AM
  3. Java Applet Runtime error
    By sarwar1234 in forum Java Applets
    Replies: 12
    Last Post: 09-21-2010, 02:26 PM
  4. A fatal error has been detected by the Java Runtime Environment:
    By jayanti kumari in forum Advanced Java
    Replies: 8
    Last Post: 08-16-2010, 07:31 AM
  5. Replies: 5
    Last Post: 07-07-2010, 12:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •