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
861 - slow judge?
Moderator: Board moderators
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 861 - slow judge?
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!
Re: 861 - slow judge?
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?
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?
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 861 - slow judge?
in JAVA BufferedReader and BufferedWriter are faster than Scanner.
Check input and AC output for thousands of problems on uDebug!
Re: 861 - slow judge?
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..
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..
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 861 - slow judge?
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.
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!