Блог пользователя Mediocrity

Автор Mediocrity, 12 лет назад, По-русски

Всем привет!

Приглашаю вас принять участие в Codeforces Round #260(div. 1 and div. 2), который начнётся 8 августа в 19:30 по московскому времени.

Задачи были подготовлены мной, netman и randrew. Это наш первый раунд и мы очень надеемся, что он вам понравится).

Большое спасибо Gerald, CherryTree, vlad107 и dimad за помощь в подготовке раунда и MikeMirzayanov за создание Codeforces и Polygon.

Удачи всем!

UPD. Распределение баллов для первого и второго дивизиона будет таким 500-1000-1500-2000-2500

UPD. Приносим извинения за большую очередь в конце соревнования.

UPD. Поздравляем победителей.

Div. 1

  1. tourist

  2. cgy4ever

  3. LayCurse

  4. ecnerwala

  5. snuke

Div. 2

  1. allthecode

  2. gotowork

  3. SMAKH

  4. saikrishna17394

  5. PashaChemerys

Разбор на русском

  • Проголосовать: нравится
  • +383
  • Проголосовать: не нравится

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +24 Проголосовать: не нравится

Здорово! Раунд новых авторов, тем более от земляков) Думаю, будут хорошие задачи.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +20 Проголосовать: не нравится

Хороших начинаний Вам!

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +47 Проголосовать: не нравится

It's good to see new problem setters coming up with DIV1 rounds at their first appearance :)

Thanks to Mediocrity,netman & randrew. We expect more DIV1 rounds from you :) :)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

The first time so early I am.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +65 Проголосовать: не нравится

Hope Strong Pretests :D

»
12 лет назад, скрыть # |
 
Проголосовать: нравится -13 Проголосовать: не нравится

Hope Strong Pretests :D

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +72 Проголосовать: не нравится

netman,(one of the authors of today's contest) you profile is very inspiring. starting from CF 105 div2, minimum rating 1105 at 143 div2 and then a story to tell everyone the secret of reaching 2192 at round 259 div1 ! its really amazing to see rising someone from the very beginning with his passion and practice that reminds me my lack of effort to attain that level. Wish you more and more success:)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +157 Проголосовать: не нравится

Chinese Div1 rounds chain is finally broken :D

»
12 лет назад, скрыть # |
 
Проголосовать: нравится -29 Проголосовать: не нравится

Hope for math problems :)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

Thanks for taking the time to prepare the problems. Feeling excited! Good luck contestants. (◕ܫ◕)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

My first time in a Div 1 round, I hope I can make a submission.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится -14 Проголосовать: не нравится

Weak pretests please ;D

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +31 Проголосовать: не нравится

The first ever non-Chinese Div.1 round in 40+ days(excluding tournaments)!!!

Hoping to get back to yellow :D

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

Hope for good problem. Hope for more hack.hf & gl

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

the shortest contest post ever

»
12 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +13 Проголосовать: не нравится

Как принято в некоторых других странах, откомменчу: Удачи всем белорусам на контесте!

Земляки, не позволяйте меня заминусовать:)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится -25 Проголосовать: не нравится

Жалко, что без пони, но зато и без спойлеров.

Special translation for MinakoKojima: It's pity without pony. But it's good there are no spoilers this time.

Big thanks to vas.and.tor for help with the special translation for MinakoKojima.

Thank to sebinechita (not a user codeforces (and it is not a user)) for help with translation helpful to vas.and.tor.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I start now FOR first time .

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

Good luck & it's my first time to be purple to take part in Div 1 !

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

a good news for me, a Chinese coder who don' t do well in math... most of last Chinese Rounds are also nightmares for me :p(anyway, learning is always a goos idea, through perhaps you can' t adapt it well

»
12 лет назад, скрыть # |
 
Проголосовать: нравится -12 Проголосовать: не нравится

Is it the first Belarusian round or any other Belarusian rounds that have happened before ?

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

Coders like netman inspire us a lot for continuous practise.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится -74 Проголосовать: не нравится

The start time is confusing.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Good luck :)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

А куда делась ВКшная кнопка "мне нравится" возле отстчета до начала контеста?

»
12 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

worse прекратил "бурить"(

печалька

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

GooD LucK...:)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Div 2 задача С — просто показалось.

»
12 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится -64 Проголосовать: не нравится

I'm ready

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится

In queue

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Such CE, Much slow!!!

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

What a pity , I submitted a code in last 5 seconds and I got " Codeforces is temporary unavailable "

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +31 Проголосовать: не нравится

Problem C reminds me of the first day of IOI 2013, doesn't it? It is also clear now why you didn't thank Delinur for translations.

I like problem D a lot. Seems to be a good example, where rope sucks and sqrt-heuristics rule :) I didn't solve it during the contest, so I may be completely wrong.

Thanks for the contest, I've enjoyed it!

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve Div2 Prob C? I summed effective values obtained by all odd entries first and then checked even entries that outweighed the neighbouring odd entries, and then vice-versa. WA on pretest 11.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Как решить C Div2?

  • »
    »
    12 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Простая динамика

    dp[1] = cnt[1];
    for (int i = 2; i < MAXN; ++i)
         dp[i] = max(dp[i - 2] + i * cnt[i], dp[i - 1]);
    cout << dp[MAXN - 1] << endl;
    

    cnt[i] — кол чисел i

    • »
      »
      »
      12 лет назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      Круто, спасибо.

    • »
      »
      »
      12 лет назад, скрыть # ^ |
      Rev. 6  
      Проголосовать: нравится 0 Проголосовать: не нравится

      Я ее пытался решить, задавая в отдельном массиве "веса" действия, т.е. (mass[i] — mass[i — 1] — mass[i + 1]) Примеры:

      1 2 = -1 1

      5 4 3 4 5 = 1 -4 -5 -4 1

      4 5 7 6 2 1 8 = -1 -6 -4 -3 -5 -9 7

      И потом брать наибольший вес, удалять числа, и переопределять таблицу весов Контрпримера нет ни у кого, кто так решал? Я на 5 тесте обвалился, со своими велосипедами

      • »
        »
        »
        »
        12 лет назад, скрыть # ^ |
         
        Проголосовать: нравится 0 Проголосовать: не нравится

        Мой друг тоже писал что-то похожее и дожил до 9 теста.

        А я пытался пропихнуть жадник, и прожил чуть дольше вас — 11 тест.

»
12 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +7 Проголосовать: не нравится

now not

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Сделал попытку взлома за 2 с половиной минуты до конца контеста, а вердикта почему-то до сих пор (после конца контеста) нет. В чем может быть причина?

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Спасибо за контест))
интересно было решать, только вот по С Div 2 не успел одного взломать на long long

  • »
    »
    12 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Всю жизнь пишу массивы от i64, внезапно сегодня написал от инта, контесты утром для меня плохо складываются.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Problems are all interesting! Thanks! What a pity that can' t correct my buggy codes at last:(

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

It is unbelievable that there are many people still use long long in Div2/B although the N is 10^(10^5)..

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

It is unbelievable that there are many people still use long long in Div2/B although the N is 10^(10^5)..

»
12 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится -6 Проголосовать: не нравится

Nice round. A and B were the way div2 first 2 problems should be. C was a little nice DP. D was a real show-off of Trie + 2 x DP + Game Theory. Also heared that E was pretty hard for Div (1+2), because Div1 coders should implement C and also meybe D or E.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

How to solve problem D? Maybe I'm stupid, but I tried to solve it for quite a while, and the only solution I came up with is the straight-forward square-root optimization (store one single Treap for permutation + individual Treaps for all numbers which occur often enough). This takes per query and works literally forever (30 seconds on my machine for the worst case). But looking at the amount of people who solved it, probably there is a much simpler and much faster solution. I wonder what is it?..

  • »
    »
    12 лет назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится +24 Проголосовать: не нравится

    We have solution and it's much easier then yours.

  • »
    »
    12 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +51 Проголосовать: не нравится

    One can divide an array into sqrt(n) blocks and maintain a deque for each block. Shift operation is rather simple: for fully covered blocks, it is just one push_front and one pop_back. Partially covered blocks can be handled naively.

    To answer the second type of queries, one can maintain a count array for each block(count[i] — the number of occurrences of i within a block). For fully covered blocks the answer is just count[x]. Partially covered blocks can be handled naively again. Shift operation changes the count array in at most 2 positions per block, so it is possible to update it quickly.

    The complexity is O((m + n) * sqrt(n)).

  • »
    »
    12 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +11 Проголосовать: не нравится

    From what I could read in kutengine's solution: keep linked lists containing elements each, and remember the count of each integer for each list. Then you can do the rotating query by removing from the end of one list and prepending to the start of the next.

    That's quite beautiful, actually. I'm always surprised by sqrt-decomposition brilliance :P

»
12 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone explain this compilation error to me?

7393631

it worked after I've resubmited it (no changes were made)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve div2-D ? I tried to use suffix automaton but couldn't get an idea. Hope a nice tutorial for this problem.

  • »
    »
    12 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +1 Проголосовать: не нравится

    I guess, D is based on game theory..

    waiting for the editorial :)

  • »
    »
    12 лет назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    I think we can use bor and then for each vertex set: 1) can we Win from this position 2) can we loose from this position After it see on root vertex and print answer. http://mirror.codeforces.com/contest/455/submission/7387998

  • »
    »
    12 лет назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится +3 Проголосовать: не нравится

    trie + 2 tree traversals to check if it's always possible for first player to win and if it's always possible for first player to loose. then just check for each case:

    • first player can choose if he wins or looses a single game -> "First"

    • first player always wins a single game AND k%2 == 0 -> "Second"

    • first player always wins a single game AND k%2 == 1 -> "First"

    • first player always looses a single game-> "Second"

    • »
      »
      »
      12 лет назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      There's a case when first player can neither win nor lose for sure. Then second player wins and 71st testcase covers it.

      • »
        »
        »
        »
        12 лет назад, скрыть # ^ |
         
        Проголосовать: нравится 0 Проголосовать: не нравится

        I'll take a look, bit i think it's always possible to be sure (at least my code got AC)

        • »
          »
          »
          »
          »
          12 лет назад, скрыть # ^ |
           
          Проголосовать: нравится 0 Проголосовать: не нравится

          There are 5 different cases(but we can reduce that to 3):

          1. The first player can decide the result of the game. Then he will lose n-1 games and win the last one.

          2. The result is deterministic (first player always win or lose), in such case, if first player always wins, result depends on parity of k; otherwise first player loses.

          3. The first player can ensure a lose but cannot win, then opponent force him always lose.

          4. The first player can ensure a win but not a lose(this is more complicated and I took some time to evaluate that): assume k=1, then first player choose to win; then assume k=2, we will see that the second player can let him win, and get a first play in next game and wins; evaluating similar cases as k grows we will see that first move will always win if optimally play. So the result depends on parity of k again.

          5. The opponent can decide the result. Obviously the first player loses.

          And finally the conclusion is: If first to play can decide the result then first play wins; Then if first to play can only ensure a win, result depends on k; Otherwise first player loses.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится

After waiting for a long queue, my submission have failed on pretest after 15 minutes after the contest. I should have tested more with handwritten cases.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится -23 Проголосовать: не нравится

again power of #define int long long.....2 unsuccessful hacking attempts on my code because of this...:P

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

so many people even use long long to cin>>n in DIV2 B. and a lots of them passed.... what could i say

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

People used biginteger and modular exponentiation in div2bB!

Hacked a Java code but python code passed time limit! :(

»
12 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +63 Проголосовать: не нравится

In hacking box, font size is too small. When I was attempting to hack, I couldn't distinguish letter 1 from letter l. So I sent an hacking request and got Unsuccessful. This will be better if font (in hacking box) is not Courier New or at least not too small like this.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +24 Проголосовать: не нравится

why system testing is not started yet ?

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Oh la. What a large queue. :X

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +15 Проголосовать: не нравится

problem div1 A, at beginning I thought we remove all element equal to Ak + 1 not Ak + 1 , who is the same?

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Верно ли, что в при объединении двух деревьев если старые диаметры в них d1 и d2, то новый будет максимум из: d1, d2 и ?

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I have a question. How did this "7385674" solution passed the pretest..?? i tried to hack this with a large input. i thought it will fail to take the input. but it still passed.. and gave correct answer, how is it possible...???

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

For Div2, problem c, I used the DP : dp[i] = max(freq[i]*i + dp[i-2], freq[i-1]*(i-1) + dp[i-3]), can someone please tell me why it is wrong and why dp[i] = max(freq[i]*i + dp[i-2], dp[i-1]) is correct?,

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

What are hackings on problem A div1? At first I think some people doesn't use long long but it seems that pretests include that case.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +142 Проголосовать: не нравится

»
12 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +13 Проголосовать: не нравится

7377218

This shouldn't have happened...

Can't compile file:
g++.exe: error: CreateProcess: No such file or directory

Could you please repair it ASAP? :P

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +11 Проголосовать: не нравится

Many programs which already passed pretests get "Compilation Error", I think there must be some problems with the judge system.

»
12 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +3 Проголосовать: не нравится

Is there any problem in system tests? I submitted 2 codes for A, 1 for B and 1 for C. Instead of skipping my 1st A code, the submission page shows my B code as skipped.

»
12 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

Can anybody explain me this: 7377299 ?

UPD. This solution passed pretests; verdict became "Compilation Error" during the testing .

After resubmission, it was "In queue" until the end of testing.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +13 Проголосовать: не нравится

Кстати, в B div 1 проходило решение за O(k), надо было чуть поднять ограничения на k...

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

1H after coding phase and system test still not complete :(

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

In Div2 "A" — I checked if numbers in each pair are equal...

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

7383032 Seriously -_-...? Why?? Because of what? Is O(n log n) too slow for 3e5 -_-?

»
12 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +22 Проголосовать: не нравится

в этот раз тесты плохие. DIV2 задача A у меня прошло вообще не верное решение :) Заметил, как всегда, после блокировки задачи...

»
12 лет назад, скрыть # |
 
Проголосовать: нравится -24 Проголосовать: не нравится

Check out room 23: Slovak domination!

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can anyone explain div1-B . I was trying something with trie ....but coludnt get it ...

  • »
    »
    12 лет назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится +34 Проголосовать: не нравится

    Here it goes, hope I explain my solution well enough:

    Firstly we build a trie. The root of the trie is the empty string. Now the game proceeds as the first player starts in the root and then chooses a child to go to. Then the next player chooses a child to go to and so on until you are in a leaf, when the current person loses. Now to efficiently solve the problem you must compute two values for the root position.

    1) Can you win if you try to? (is it a Winning or Losing position)

    2) Can you purposefuly lose if you try to?

    Both are equally simple to compute. Simply start from the leaves and go up the tree computing each vertex through its children. The computation of both values is simple and is as follows:

    1) If you can move to any lost position, then the current position is won. Otherwise it's lost.

    2) If you can move to any position that CAN'T be purposefuly lost, then the current position can be purposefully lost. Otherwise it can't be.

    Now how do we compute our answer? Well let's look at a few cases.

    1) One simple case is if the root position is lost, that is you can't win if the second player plays optimally. Well then the answer is "Second" as he could easily win all games and the loser would always play first again and lose

    2) If the root position is won, and it CAN be purposefuly lost then the winner is "First". This is due to the fact that he can purposefuly lose until the very last game where he can win, no matter what k is.

    3) The last case is if the root position can be won, however it CAN'T be purposefuly lost. Well then it is obvious to see that if some of the two players wants, the game can be played in such way so that the first guy always wins. Therefore it is easy to see that if k is odd the first player will win, and if k is even the second player will win.

    Hope I helped you :)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

Why no editorial still?

I dont think editorials cannot be shown during systest (when it takes 100+ minutes)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Все кто писали Union Find без ранговой эвристики или рандомизации обломались. Оно правда работает за квадрат?

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

My submission was judged as WA on test 20 but when I use custom invocation, everything is OK. Please check! 7377515

»
12 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +21 Проголосовать: не нравится

7377531 WA with no reason? I submitted the same thing in practice and got AC...

»
12 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится -28 Проголосовать: не нравится

Thanks for minus!

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +64 Проголосовать: не нравится

I can't stand that Imagine my excitement when 1,5 min before the end of contest I finally debugged my D. Imagine my anger when few seconds later it turned out that Internet crashed in a place I was coding and I can't submit it. Imagine my anger when I got to know that my C got very weird TLE which resulted in 39->262 change of my place. Imagine my anger when I submitted D on practice and it got AC!!!! And now my C got accepted after deleting one cerr (without endl's, so it is really fast)!!! Words won't describe my irritation at that moment ^&*(%^%^*!!!!! I should have took ~10th place and I got 262th! ARGH!

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +33 Проголосовать: не нравится

I have some problem with my div 1/B submission

this is the code I submitted during the contest, and got queued until the end of the contest. The verdict said WA on pretest 1. But it appears that there is no output in the submission above.

Then I submit this code after contest, the very same code but with assertion commented, and it got accepted (I tried to post the exactly same code but the verdict is exactly the same with my first solution; no output at all).

Does anyone knows what's happened?

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can we continue to solve problems?

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится

Can we continue to solve problems?

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I see the most of the solution of DIV 2 Problem LAPTOPS solved using sorting in O(nlogn) complexity. But it can be solved in O(n) . Suppose for "Happy Alex"

price[i] < price[j] ....................equation_1 quality[i] > quality[j] ====> -quality[i] < -quality[j] .................equation_2

let's add equation_1 and equation_2

price[i]-quality[i] < price[j]-quality[j]

Difference[i]<Difference[j]

so compute all the difference , get max difference and min difference if max_diff!=min_diff

then "Happy Case" else "Poor Case"

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

It’s my first time in CF and feel 2exicited. But I got TLE for cin ,which depress me.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Why is my submission skipped? 7380034

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +15 Проголосовать: не нравится

During contest I got TLE 121 on problem C: 7391661

Exactly the same code got AC in practice: 7396418

This might be caused by server load during the contest, and I request that my in-contest submission is rejudged and considered correct.

  • »
    »
    12 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +4 Проголосовать: не нравится

    Your code in practice runs 951ms. IIRC, variation of execution time on codeforces is ~40-80ms, so nothing surprising that it failed during the contest.

    • »
      »
      »
      12 лет назад, скрыть # ^ |
       
      Проголосовать: нравится +6 Проголосовать: не нравится

      If it was WA then yes — it should be considered wrong. But IMHO if a solution once once fails time limit due to overload, and then passes, it should be considered correct.

      I can't find how such cases are considered according to Codeforces rules though. I think it's up to problem setters and administration to decide.

      • »
        »
        »
        »
        12 лет назад, скрыть # ^ |
        Rev. 2  
        Проголосовать: нравится +18 Проголосовать: не нравится

        That's not due to overload. Try submitting your solution again to practice several times (adding whitespaces to make it re-run the submission). I've just tried, and it gets TLE ~50% of the times.

        I think usually on CF they don't change their verdicts. E.g., ~3 years ago one of my problems failed getting TLE and passed in practice with 100ms margin. Back then they probably had slightly different machines, and now it's not that bad.

    • »
      »
      »
      12 лет назад, скрыть # ^ |
       
      Проголосовать: нравится -19 Проголосовать: не нравится

      7396999 Here it passed again, so the fail during contest is definitely due to system load.

      • »
        »
        »
        »
        12 лет назад, скрыть # ^ |
         
        Проголосовать: нравится +13 Проголосовать: не нравится

        And here it failed: http://mirror.codeforces.com/contest/455/submission/7397092

        I'm absolutely sure it's due to the natural variance of execution time; 40ms margin is very tiny.

        • »
          »
          »
          »
          »
          12 лет назад, скрыть # ^ |
           
          Проголосовать: нравится -19 Проголосовать: не нравится

          I agree that it might equally fail and pass. My question is, how are such cases handled on CF? May be some of these points:

          • Solution is incorrect, if it got TLE at least once;
          • Solution is correct, if it passed TLE at least once;
          • The contest verdict is taken into account, no matter what happens in practice;
          • This is a matter of appeal with inspection of a particular case.

          or something else. I would appreciate an official comment from problemsetters/administration.

          Anyway, this particular solution had the same chance to pass during the contest, and I might be somewhere around 50th place, not 286 :)

          • »
            »
            »
            »
            »
            »
            12 лет назад, скрыть # ^ |
             
            Проголосовать: нравится 0 Проголосовать: не нравится

            I believe it's "submission is correct, if it got AC on the systest", with "submission is systested if it passed all pretests, is the last submission of that user on that particular problem and wasn't skipped for cheating". So it has to pass all pretests on 2 runs and all other tests on 1 run. Of course, with possible reruns.

            Maybe you noticed that usually, the authors of the round have solutions that fit in the time limit comfortably. That's because the TL is chosen so that a reasonable constant factor wouldn't pose a problem, usually 2-5 times that original solutions' runtime. And I think it's safe to say that a reserve for cases such as yours is included.

          • »
            »
            »
            »
            »
            »
            12 лет назад, скрыть # ^ |
             
            Проголосовать: нравится +10 Проголосовать: не нравится

            The practice is that the system test results are final in this case.

  • »
    »
    12 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +13 Проголосовать: не нравится

    Check out my submissions in practice — I tried submitting your code several times (the only difference is adding a comment) and got AC 2 times out of 9. Based on this, I don't think a rejudge would make much of a difference, unless the code was rejudged until it got AC (roughly 1-5 times, I'd guess).

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Когда будет разбор задач?

»
12 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +2 Проголосовать: не нравится

where is the rating result ?? ?? ?

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится
»
12 лет назад, скрыть # |
Rev. 5  
Проголосовать: нравится +21 Проголосовать: не нравится

Я правильно понимаю, что Дэшка и за на запрос решается? 7394913

И ещё, это(7397416) случайно не квадратное решение Ешки? Точнее говоря, . Это было так задумано, ограничивать Amax ≤ 10000, чтоб наивное решение заходило быстрее чем любое другое, пусть даже с правильной асимптотикой? =)

UPD. Всё-таки это тесты слабые. На тесте с массивом вида 1 10000 2 10000 3 10000 4 ... этот код работает больше 2х секунд в запуске.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +13 Проголосовать: не нравится

Problem E has 21 pretests Wrong answer on test 23

And it was a pretty easy bug to catch, too... :(

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

I used grundy numbers for problem B Div-1. I have no idea where it is failing. Can anyone please help me find the error?

Link: My submission

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Why the output is unexpectedly 0 in 43rd test case ? Submission id: 7389527

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Is it just me or was Div1-B really confusing? I thought during the contest that the players will play optimally in each game, and not considering all k games....

  • »
    »
    12 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    No, the result is determined by the following sentence:

    "Guys decided that the winner of all games is the player who wins the last (k-th) game."

    • »
      »
      »
      12 лет назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      Actually you're right. But for example after contest before system test, I asked my friend who tried to solve Div1B, "Play for win, for each game" is optimal?, he said "I didn't think it". Problem doesn't say "You don't need to play for win, for first k - 1 game.", it says "You have to play win, for last game." So you have to make a little observation.

  • »
    »
    12 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    I don't know if confusing is the right word. It's just a matter of analyzing the problem fully, paying attention to every detail.

    I did consider K games, but I forgot about the fact that people can intentionally lose. (I thought of using K mod 2 to determine the output once I analyze a single game).

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +22 Проголосовать: не нравится

Обновите рейтинг, я спать хочу

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +43 Проголосовать: не нравится

Five hours have passed after the contest and the rates have not been updated yet! What is the problem?

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +13 Проголосовать: не нравится

Why is not updpate rating ? I hope very more about this

»
12 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +9 Проголосовать: не нравится

Why there is a Hack with status "Waiting" after contest?

Look for 107221

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Finally! Ratings have been updated, just now.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

I want to ask a question ,why my div 2 C problem's final test statue is Skipped?I am so puzzled.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Would you please post the editorial for this contest :D ?

Mediocrity netman randrew

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

would anyone like to suggest how to solve problem E- DIV2 Efficiently ?

  • »
    »
    12 лет назад, скрыть # ^ |
    Rev. 4  
    Проголосовать: нравится +6 Проголосовать: не нравится

    Firstly , you are given a graph which is a forest(note every connected component is a tree, as there is only one unique path between any pair of vertices).

    Now , to find the longest path in a tree , you first start dfs from the any vertex u. Let, v be the vertex we find which is the most deep node from u. Now from v you do a dfs, and find the most deep node. This height is the longest path.

    When you have found the longest path of a tree L, you insert the edges into a disjoint set data structure(actually you do it during taking the input). You find the representative of that tree and then let representative be r. So you mark longest[r] = L. Here is a thing , the longest path in a tree is called the diameter of the tree.

    So , we have found the longest path of each tree. Now, answering query 1 is pretty straightforward. You find the set-representative r and print longest[r]

    for the 2nd type , note that , for a component , if longest path is divisible by 2 you can take the middle vertex(the center) otherwise you can take any of the middle two vertex. So if you choose this way , in both component where x and y lies, the path length will be (Let r1 ,r2 be representative of x,y) ceil(longest[r1]/2)+ceil(longest[r2]/2) + 1. Now when you connect the component , the new longest path will be maximum between previous two components and this recently emerged path through x and y.

    note , if you connect to any other vertices you dont get shortest long path, why ? let you have choosen u and v that is not center. then the longest path is (larger radius end1 -> center1 -> u -> v-> center2->larger radius end2) which is defineitely larger then previous.

    Hope it helps.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +24 Проголосовать: не нравится

What is the intended solution of task E?

My submission(7390143) is just an O(nm) brute force with few pruning:

  1. If x[i] < x[i+1] < .. < x[i+k] then start with x[i] is not worse than x[i+1], x[i+2], .., x[i+k].

  2. If x[i] >= x[i+1] >= .. >= x[i+k] then start with x[i+k] is not worse than x[i+1], x[i+2], .., x[i+k].

Since the range of number is 10^4, the number of computation will be under 10^5 * 10^4 / 2. (worst case is x[] = {1,2,1,2,1,2,..})

  • »
    »
    12 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    {1,2,1,2,1,2,..} isn't worst case. With test x[]={1, 10000, 2, 10000, 3, 10000, 4, 10000, ...} your code works 4 seconds.

  • »
    »
    12 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +8 Проголосовать: не нравится

    Suppose you have partial sums at S[]. I used the fact that if you calculate f (i, j) starting at x[k], then you have

    f(i, j, k) = (S[j] - S[k]) + (i + k - j) * x[k]

    Which is a line, so you can use something similar to convex hull trick to get best k in log n: 7397318

»
12 лет назад, скрыть # |
Rev. 8  
Проголосовать: нравится +44 Проголосовать: не нравится

In problem D solution can pass: 7401453. Is it ok?

UPD. 2808 ms with some shenanigans: 7401820

UPD 2. Looks like tests are weak and there is no test, where all query operations make more than 2e9 operations... 7401924

UPD 3. By the way, in lots of tests you do not need to output anything and there (if I am not mistaken) are no tests, where q = 105 and you need output several (but less than 100) lines. Of course, such testset is vulnerable to obvious pruning: if you have nothing to output don't do anything.

UPD 4. Anti-bruteforce tests were added. Thanks to authors.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

I love this contest, even I could't go to orange in this round :( The problem C in div 1 is interesting. Love it. I expect more Div 1 rounds from guys.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

In Div2 E/Div1 B, is the case of n=1 and the length of string = 100000 in the test? Some people use recursive, but how do you decide whether you can use recursive or not?

»
12 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +1 Проголосовать: не нравится

Problem B Div2 :

What is the difference between these 2 codes ?

Hacked : http://mirror.codeforces.com/contest/456/submission/7385428

Accepted : http://mirror.codeforces.com/contest/456/submission/7399213

  • »
    »
    12 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    I don't know how scanf read overflow integer, but i think the accepted solution using int got super lucky accepted, since both solution is wrong because N can far exceed the limit of int or even unsigned long long, and should't always produce the correct answer.

  • »
    »
    12 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    As it was mentioned in the previous comments, cin will just overflow the integer while scanf will input the integer mod 2^64 (not completely sure on this). Since 2^64 is divisible by 4 (which is what you're checking), it apparently doesn't have any effects on the result.

  • »
    »
    12 лет назад, скрыть # ^ |
    Rev. 3  
    Проголосовать: нравится +1 Проголосовать: не нравится
    cin>> n   !=   scanf("%d",&n)
    

    =>

    Hacked  and  Accepted
    

    He is really lucky

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Problem Civilization is very similar to IOI 2013 problem Dreaming. During the competition itself I simply took my old code for Dreaming and modified it. I had some bugs and it took me more time to fix it than it would to code a new solution, however in the end this problem is just a simplified version of the IOI problem.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I am new to Codforce. plz tell me where to find the solution of codeforce round #260. thanks

»
12 лет назад, скрыть # |
 
Проголосовать: нравится -8 Проголосовать: не нравится

For problem Div 1 D, I am getting accepted using vector cnt in the struct block, but when I change it to int * cnt, I get wrong answer on test case 5. Actually it is giving garbage value on a specific index.

Accepted Code
Wrong Code

Please help, thanks in advance !!!

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится
»
12 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

Я очень удивлён, что таска С такая лёгкая ( жаль на самом контесте я этого не увидел).

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Problem A Div.2 I don't sort and accept O(N) , but have many people sort, even Editorial use sort O(N log N). My submission

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

Is the editorial actually coming out in English at all?

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

in problem C div 1 when we calculate the diameter of the new tree why do we mazimize between the 2 small trees ??

  • »
    »
    12 лет назад, скрыть # ^ |
    Rev. 3  
    Проголосовать: нравится 0 Проголосовать: не нравится

    Because when you merge two trees its diameter will be the length of its longest path. It is not about maximizing, it is about diameter definition.

    More precisely, in this problem we are merging in a way that the diameter of the resulting tree is minimized. Merge means adding an edge that connects two separate trees. The optimal way to do this is by connecting its centers.

    Trees can have one or two centers. If a tree has only one center its eccentricity will be exactly , if a tree has two centers, they will be adjacent and they will have as eccentricity. Both cases can be summarized as the ceiling of .

    Finally, when you merge two trees, you must take into account that the resulting diameter can be the diameter of one of the original trees, or the new longest path created by connecting its two centers. That's why you see this max formula on this problem.

»
12 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Ignore this; it seems that the English editorial is up.