861 - slow judge?

The forum to report every bug you find or tell us what you'd like to find in UVa OJ

Moderator: Board moderators

Locked
yoojioh
New poster
Posts: 5
Joined: Sun Apr 29, 2012 6:47 pm

861 - slow judge?

Post by yoojioh »

Hi,

I keep getting TLE in 861 problem with 3 sec limit,
but on my laptop, more than 10 cases run in 1 second.

So I just submitted a program that always prints "1" for ever case intentionally,
then I found it just took "1 SECOND" for just reading inputs and printing "1"s..

Why is the judge so slow? or using Java is a problem here??

Thanks
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 861 - slow judge?

Post by brianfry713 »

Either optimize your code and/or rewrite it in C. Make sure you are using faster I/O methods.
Check input and AC output for thousands of problems on uDebug!
yoojioh
New poster
Posts: 5
Joined: Sun Apr 29, 2012 6:47 pm

Re: 861 - slow judge?

Post by yoojioh »

Well, but just the simple program (surely not correct one) like

public static void main(String[] args){
Scanner sc = new Scanner(System.in(;
while(true){
if(some condition) break;
System.out.println(1)
}
}

is so slow... took more than 0.5 secs.
(And not sure if there is more efficient class/method to read line from stdin than Scanner.)

Is this the problem or bug of JVM being used in uva judge?
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 861 - slow judge?

Post by brianfry713 »

in JAVA BufferedReader and BufferedWriter are faster than Scanner.
Check input and AC output for thousands of problems on uDebug!
yoojioh
New poster
Posts: 5
Joined: Sun Apr 29, 2012 6:47 pm

Re: 861 - slow judge?

Post by yoojioh »

thank you so much for your replies, brianfry713,

but the java code as simple as

import java.io.*;
public class Main{
public static void main(String[] args) throws IOException{

InputStreamReader inp = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(inp);

while(true){
String[] str = br.readLine().split(" ");
int a = Integer.parseInt(str[0]);
int b = Integer.parseInt(str[1]);
if(a +b == 0) break;
System.out.println(1);
}
}
}

takes 0.8 seconds, whereas a program which just terminates after printing single "1" takes 0.1 seconds.

Well... i think i should rewrite my code in c++ and then see if i can complain about the support of JAVA in uva..
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 861 - slow judge?

Post by brianfry713 »

I just got a JAVA solution for this problem AC in 0.644 sec using the I/O techniques at:
http://online-judge.uva.es/problemset/d ... .java.html

Yes c is faster. If you use JAVA make sure your code is fast enough.
Check input and AC output for thousands of problems on uDebug!
Locked

Return to “Bugs and suggestions”