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

Обсуждение задачи 1003. Чётность

1003- Why just 2 seconds?
Послано Ksenya 29 дек 2003 22:08
I think 2 seconds is bad Time Limit. Also I don't know how many input
tests contains each test.
So I tried everything: like binary search and hash-function. But
always TLE.
Do you think 2 seconds is enough time?
Re: 1003- Why just 2 seconds?
Послано buggzy 28 мар 2004 22:05
There is at least O(n*n) algorithm for 1003.
Re: 1003- Why just 2 seconds?
Послано Vladimir Yakovlev (USU) 29 мар 2004 02:34
I solved it in O(n*n) time and get AC in 0.125 sec. So, 2 seconds is enough timelimit for this problem.
Re: 1003- Why just 2 seconds?
Послано buggzy 29 мар 2004 10:53
My algo is:

Each point have attibutes "parity" and "connectivity compontent number". When processing each segment, we check if it
- form a new connectivity component - O(1)
- extends existing connectivity components - O(1)
- connects existing CCs - O(N) for glue operation
- form a cycle in the existing CC - O(1)

This stage is O(n*n). It's quite enought for AC, but I'm still interested in more efficient algorithm :) Any ideas? :)