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

Обсуждение задачи 1028. Звёзды

How to solve so fast? Help me, please!
Послано Aleksei Zobnin 17 янв 2002 16:26
A hint for you.(+)
Послано shitty.Mishka 17 янв 2002 18:12
There are a lot of problems where the same idea can be used.

Try to think of such a problem first:
You have a string of n zeroes.
Then there will be a series of either requests or data changings
(they may follow in any order).
On a request you have to output the first non-zero element of the
string (or say that all the elements are zeroes).
On a data changing you have to increase or decrease the value of one
element.

The obvious algorythm will take you O(1) at each data changing and
O(n) at each request. Try to think of an algorythm that will take
O(Sqrt(n)) at each request and at each data changing.

I'm sure that if you solve this problem, you'll be able to solve the
stars problem as well.

Good luck!
Thank you! I've got AC!
Послано Aleksei Zobnin 17 янв 2002 22:03
That's great!
Re: A hint for you.(+)
Послано Christopher Moh 18 янв 2002 20:13
> There are a lot of problems where the same idea can be used.
>
> Try to think of such a problem first:
> You have a string of n zeroes.
> Then there will be a series of either requests or data changings
> (they may follow in any order).
> On a request you have to output the first non-zero element of the
> string (or say that all the elements are zeroes).
> On a data changing you have to increase or decrease the value of
one
> element.
>
> The obvious algorythm will take you O(1) at each data changing and
> O(n) at each request. Try to think of an algorythm that will take
> O(Sqrt(n)) at each request and at each data changing.
>

Hi,

are you suggesting an O(n sqrt(n)) solution for stars?  Well, I think
that O(n log n) suffices, but O(n sqrt(n)) should be able to beat the
time limit.

As for that question, I think I can get O((log n)^2) request and O
(log n) update.  I am sure other better algorists can beat this
complexity however.

Thanks.
O(1) for Change and O(lg(n)) for Request...
Послано Locomotive 17 фев 2003 10:17
But how i solve stars with it?
Re: O(1) for Change and O(lg(n)) for Request...
Послано Sergei Pupyrev (USU) 3 мар 2003 19:44
Can you tell me how to do it?
mailto: pserega@r66.ru
Thanks.