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

Обсуждение задачи 1129. Покраска дверей

About Java...
Послано DWED 7 авг 2008 18:17
Java on this server is EXTREMELY slow!
Moreover - it is really strange - don't you ever notice how it gives you "Compilation Error" on @Overriden annotation automatically generated by Eclipse.

On maximal set (K100 graph) on my P4 3GHz my last solution works 0.03s, on server it works 5 times longer - 0.17s! Fantastic!

Initially on my machine solution worked 0.400s - it is TLE, no words. To make it faster I tried to avoid all collections. I thought "DAMN! They want all programmers to write like with raw C/Pascal". After I've finished, it worked 0.360s - so collections did not a great slowdown.

"Output is slow?" I constructed output in StringBuffer, and "viola" - twice speed-up (0.170s).
"That's enough" - I thought and got TLE again - now i know about 5x time scale, but then...
I switched of my algo and output and found that all time (0.150s) is taken by input.
I did input with Scanner class, now it is time to throw it away. Just a simple method for input:
>public final static int nextInt() throws IOException {
>>InputStream in = System.in;
>>int i = in.read() - 48;
>>while (i<0) {
>>>i = in.read() - 48;
>>}
>>int ret = i;
>>i = in.read() - 48;
>>while (i>=0) {
>>>ret = (10*ret) + i;
>>>i = in.read() - 48;
>>}
>>return ret;
>}

"Bingo!" - my solution now works 0.03s. But on server it is 0.03x5=0.15. So BEWARE!
Re: About Java...
Послано [SPbSU ITMO] WiNGeR 7 авг 2008 23:26
I suppose that's because server use JDK1.5, not 1.6
Re: About Java...
Послано tiancaihb 28 авг 2009 07:22
Maybe their method of calculating Running time is different