ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1006. Квадратные рамки

to admin and java developers: input problems
Послано ar4ie 4 окт 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
Послано Oleg Strekalovsky aka OSt [Vologda SPU] 4 окт 2009 23:14
ar4ie писал(a) 4 октября 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
Послано ar4ie 5 окт 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
Послано Fyodor Menshikov 6 окт 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
Послано tiancaihb 6 окт 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
Послано Oleg Strekalovsky aka OSt [Vologda SPU] 6 окт 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
Послано ar4ie 7 окт 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
Послано Fyodor Menshikov 8 окт 2009 03:08
ar4ie писал(a) 7 октября 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
Послано Fyodor Menshikov 8 окт 2009 03:09
ar4ie писал(a) 7 октября 2009 02:05
complexity objects are used by TEST program to generate time limit

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