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

Обсуждение задачи 1806. Мобильные телеграфы

Moonstone [Samara SAU] Java [6] // Задача 1806. Мобильные телеграфы 1 ноя 2010 01:57
Is it possible to solve it in Java without any special tricks?
I got MLE #16 any time when I submitted it in Java. Of course, the same C++ code gets AC and uses 35 MB.

I think that it is not good when equal solutions get different verdicts. Am I right? Admins, maybe you should increase memory limit?

Edited by author 01.11.2010 10:11
Warlock Re: Java [5] // Задача 1806. Мобильные телеграфы 1 ноя 2010 15:39
Maybe you have problem with huge amount of strings while construct graph. std::string is mutable, but java.lang.String is immutable and you not call garbage collector for removing unnecessary copies. Java solution without strings require only 12MB http://acm.timus.ru/status.aspx?space=1&num=1806&author=38899
Moonstone [Samara SAU] Re: Java [4] // Задача 1806. Мобильные телеграфы 1 ноя 2010 22:55
I used strings only for reading input (not too much memory), then I used arrays of byte to store numbers and longs to keep them in map.

Your 12 MB solution is too perfect :) Many other C++ solutions use about 40 MB and, rewritten in Java, they will be MLE. It means that C++ and Java are not equal in their opportunities for this problem. I don't like this. And you?

By the way, Saratov provides programmers 256 MB for each problem. Why Timus can not do the same?
KALO Re: Java [3] // Задача 1806. Мобильные телеграфы 6 ноя 2010 23:01
Do not create the whole graph forward, just get the neighbours for the current vertex which is already removed from heap, this is the only trick :). I've got AC with standard java HashMap and PriorityQueue.
Ibragim Atadjanov (Tashkent U of IT) Re: Java [2] // Задача 1806. Мобильные телеграфы 7 ноя 2010 06:17
wont it give tl if each step you go through 50000 neighbours.
About n*n/2 in worth case
Sergey Lazarev (MSU Tashkent) Re: Java [1] // Задача 1806. Мобильные телеграфы 7 ноя 2010 11:00
Each vertex has at most 135 neighbours.
Ibragim Atadjanov (Tashkent U of IT) Re: Java // Задача 1806. Мобильные телеграфы 9 ноя 2010 02:14
ur right accepted. Thanks.
Thanks to KALO too for the help.