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

Обсуждение задачи 1553. Caves and Tunnels

Why WA?...
Послано Victor Barinov (TNU) 22 сен 2007 20:28
My algo is O(n * sqrt(n)) But i have WA on test 18. My solution gives same answers with brute force solution on my random tests. But what is 18-th test? Can anybody help me?
Re: Why WA?...
Послано Vedernikoff Sergey 22 сен 2007 20:34
Maybe, arithmetic overflow? Some answers may not fit in the standard 32-bit integer types...
Re: Why WA?...
Послано Victor Barinov (TNU) 22 сен 2007 23:57
Really?
Yes, I use usual int instead __int64. But in problem statement Q <= 10^5 and V <= 10^4 for all I queryes. So all values on nodes is <= 10^5*10^4. It is less than 2^31-1. But... maybe I misuderstud anything?
BTW I will try submit with __int64 :)
Thank You!

Any more ideas?
Re: Why WA?...
Послано Paul Diac 23 сен 2007 00:05
It fits in 32 bit integers. (I got AC using long). I also used O(n * sqrt(n)) (teoretically) but I can't think why you get WA on test 18... there must be a mistake someware.
Re: Why WA?...
Послано Victor Barinov (TNU) 23 сен 2007 02:26
AC now!

here it is program that generated contrary test for my solution:

n = 10000;
printf( "%d\n", n );
  for  (i = 0;  i < n-1;  ++i)
  {
      printf( "%d %d\n", random(i+1)+1, i+2 );
  }
m = 1000;
printf( "\n%d\n", m );
k = random(m);
    for ( i = 0 ; i < k ; i++ )
        printf( "I %d %d\n", random(n) + 1, random(10001) );

    for ( i++ ; i < m ; i++ )
        printf( "G %d %d\n", random(n) + 1, random(n) + 1 );
Re: Why WA?...
Послано Khúc Anh Tuấn 27 сен 2007 00:41
How can solve this problem in O(N * sqrt(N)) ?? Is it simple to implement ?

My solution is O(N * log^2(N)). But it's very complex and slow ( 4.25s )
Re: Why WA?...
Послано Alias (Alexander Prudaev) 2 окт 2007 09:29
my program work about N*sqrt(N) but i have TL 17
any ideas about this test?
Why TL?????????
Послано Oybek 15 дек 2007 17:16
Can U tell me about ur method

this is my email oybek_all@yahoo.com
Re: Why TL?????????
Послано Denis Koshman 14 июл 2008 21:42


Edited by author 03.08.2008 14:40
No subject
Послано KantSU: Vashegin Roman 3 сен 2008 00:06
help me, please!!  How solved? What algorithm? Tried through LCA and RSQ but could not....mail: Vashegin_roman@mail.ru
Re: No subject
Послано Denis Koshman 9 сен 2008 02:43
Build clusters of O(sqrt(N)) in size using DFS-inside-DFS. Outer clusters tree will have O(sqrt(N)) diameter. Optimize by skipping a cluster completely when you find a way. When you increase radiation level, enumerate all "downward portals" to other clusters passing through incremented node, and update their skip-values (maximal radiation level on the path from downward portal towards upward portal to parent cluster). Keep separate list of in-cluster edges. Although outer cluster tree's diameter is O(sqrt(N)), its size is still O(N) (there can be a lot of tiny leaf clusters). You don't want to enumerate all of them if you want to stay at O(sqrt(N)) during increments :)

Edited by author 09.09.2008 02:44
Re: No subject
Послано svr 23 янв 2009 15:17
More simply:
Divide Tree in sqrt(N) layers and in clusters.
If cluster small jumping through layer when forming
answer on 'G' query, but renewing for verteces of this cluster information on each 'I' query.
If cluster big go through it by step by step but in this case renewing information only for one vertex in 'I' query.
Re: Why WA?...
Послано cxjyxx_me 28 апр 2012 07:02
why we have to use __int64?