ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1006. Square Frames

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
Posted by Oleg Strekalovsky aka OSt [Vologda SPU] 4 Oct 2009 23:14
ar4ie wrote 4 October 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.
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=java
Re: 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
Posted by Fyodor Menshikov 6 Oct 2009 01:02
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
Posted by tiancaihb 6 Oct 2009 18:04
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
Posted by Oleg Strekalovsky aka OSt [Vologda SPU] 6 Oct 2009 21:02
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
Posted by Fyodor Menshikov 8 Oct 2009 03:08
ar4ie wrote 7 October 2009 02:05
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
Posted by Fyodor Menshikov 8 Oct 2009 03:09
ar4ie wrote 7 October 2009 02:05
complexity objects are used by TEST program to generate time limit

And standard fragment causing time limit is "while (true);".