to admin and java developers: input problems
Posted by
ar4ie 4 Oct 2009 16:25
I wrote a java test program that get time limit only if input chars are wrong. There is main piece of code:
char c = image[i][j];
if (c >= 256) {
Object o = new Object();
synchronized (o) {o.wait();}
}
And it works! I get time limit!
Cutting of chars don't helps too:
image[i][j] = (char) (image[i][j] & 0xFF);
Algorithm works locally but fails on first test of judge executor.
For reading chars I used simple Scanner wrapped to System.in.
Is it encoding problems? Will be great to know right char codes for java or at least get some test file.
Re: to admin and java developers: input problems
I wrote a java test program that get time limit only if input chars are wrong. There is main piece of code:
char c = image[i][j];
if (c >= 256) {
Object o = new Object();
synchronized (o) {o.wait();}
}
And it works! I get time limit!
Cutting of chars don't helps too:
image[i][j] = (char) (image[i][j] & 0xFF);
Algorithm works locally but fails on first test of judge executor.
For reading chars I used simple Scanner wrapped to System.in.
Is it encoding problems? Will be great to know right char codes for java or at least get some test file.
What is that??? O_o
I about :
Object o = new Object();
synchronized (o) {o.wait();}
Read about reading by Java at
http://acm.timus.ru/help.aspx?topic=javaRe: to admin and java developers: input problems
Posted by
ar4ie 5 Oct 2009 23:28
1. It's alternative to Thread.sleep().
2. I've already read that topic.
Anyway I still have referred problem.
I found only few java acceptance of this task and last at May of this year. TO ADMINISTRATOR: please check encoding of your java judge executor.
Re: to admin and java developers: input problems
FAQ:
Scanner scanner = new Scanner(System.in, "ISO-8859-1");
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in, "ISO-8859-1"));
PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out, "ISO-8859-1"));
Re: to admin and java developers: input problems
Well, for test file you can find a generator in the next thread. Input data is located in c:\in.txt if you need it... Its data is the same format as that on OJ, i think.
Edited by author 06.10.2009 18:05
Re: to admin and java developers: input problems
WTF. Why you need any threads and other complexity objects??
Use Scanner(or BufferedReader or StreamTokenizer),PrintWriter and be happy =)
Edited by author 06.10.2009 21:03
Re: to admin and java developers: input problems
Posted by
ar4ie 7 Oct 2009 02:05
Thank's Oleg! I just miss encoding parameter on scanner creating.
PS: complexity objects are used by TEST program to generate time limit (on timus judge executor) when input data is wrong (char > 256)
Anyway thank's all! I got this task :)
Re: to admin and java developers: input problems
complexity objects are used by TEST program to generate time limit
Standard behaviour for checks is runtime error. Usually by "throw new Error();" statement.
Re: to admin and java developers: input problems
complexity objects are used by TEST program to generate time limit
And standard fragment causing time limit is "while (true);".