SPOJ ARRAYSUB

Getting Runtime Error

OK I checked with many people and I came to know that there is a bug in that problem. Many codes which should have gotten a TLE or WA are getting NZEC for no reason whatsoever. I tested your code and it is giving WA for this (and other) test case:

12

1 2 3 3 1 2 4 5 1 1 2 3

3

Your output:3 3 3 2 4 5 5 5 2 3

Expected output: 3 3 3 3 4 5 5 5 2 3

I tried this problem using Segment Tree and got accepted.

1 Like

my code shows WA hehe

http://ideone.com/kjyPlP

#python

I also solved this problem using Segment Tree.

@michelangelo The class name doesn’t matter, all my java programs have their class names according to the problem code.
Main isn’t required.

Remove this line:

br.readLine();

which comes after


int n=Integer.parseInt(br.readLine());

@michelangelo now it ran till judge 5,after which again the verdict was runtime error(NZEC)

@michelangelo I have modified the code. Now i can have multiple instances of any number by using a Map. So i am still getting wrong answer Oauvj9 - Online Java Compiler & Debugging Tool - Ideone.com .Also the above posted test case is working.

This is just a check. When I used fast I/O in my code, it showed WA. Try using scanner in place of buffered reader. Tell me if you are getting WA or TLE now.

1 Like

Yup checked it. Remove buffered reader and use scanner and you’ll get AC.

PS: No wonder there are only 33 correct submissions in Java.

1 Like

@michelangelo Yes, Using Scanner did get it accepted. This is the first time i am seeing this. Using slower input method is accepted :D.

1 Like

@michelangelo Can you please look into this discussion. :stuck_out_tongue: SPOJ BYTESM2 - general - CodeChef Discuss

I’ll check that. Please do accept the answer so that the question can be closed.