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

Автор cgy4ever, 10 лет назад, перевод, По-русски

Привет всем!

В понедельник третьего февраля 2014 года в 19:30 по московскому времени состоится Codeforces Round #228 (Div1 + Div2).

Этой мой второй раунд на Codeforces (кликните сюда, чтобы посмотреть предыдущий). Как обычно, в раунде будет семь задач: две — только для Div2, две — только для Div1 и три общие задачи. Точно так же, как и в прошлый раз, главным героем задач раунда будет лиса Ciel.

Благодарю Gerald за тестирование задач и MikeMirzayanov за проект Codeforces и систему Polygon.

Желаю удачи и фана от решения задач!

Распределение баллов будет анонсировано позже. А разбор задач будет опубликован сразу после системного тестирования.

Кроме всего прочего, вчера в Китае отмечали новый год. Поздравляю всех, кто отмечал этот праздник! И, конечно, я очень рад, что именно я автор первого контеста в новом году.

Update1: Приятная новость для участников Петрозаводских сборов. Top 20 участников сборов по итогам этого раунда, которые придут на закрытие, получат футболки от Codeforces.

Update 2: Распределение баллов по задачам стандартное. (500-1000-1500-2000-2500).

Update 3: Приносим извинения, раунд перенесен на 10 минут по техническим причинам.

Update 4: Продолжительность соревнования увеличена на 5 минут.

Update 5: Contest ended, thanks for your participating! I'll post the editorial soon.

Update 6: разбор.

Победители:

DIV1:

  1. tourist
  2. PavelKunyavskiy
  3. Egor
  4. 2222
  5. dreamoon_love_AA

К сожалению, никто не решил задачу Е. Решение Egor-a могло пройти тестирование, если бы TL был бы равен 7 секундам, вместо 6. Какая жалость!

DIV2:

  1. I_love_Hoang_Yen
  2. iaacboy
  3. GoldExperience
  4. shivatejesh
  5. lordpawel

Только они решили все предложенные задачи!

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

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

Wow, a new contest. Thanks for preparing problems and I think I will love this contest:) PS: Orz

»
10 лет назад, # |
  Проголосовать: нравится +37 Проголосовать: не нравится

Hm.. there's also a TopCoder SRM earlier on Monday. I wonder if I will be able to participate in both TC and CF :)

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

Your last contest had nice problems.

Thank you for creating another contest.

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

На этом контесте я буду пить не чаёк, а яжку

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

К контесту готов!

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

I'm definitely looking forward to the 1st contest in the Chinese new year! 新年快乐!

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

Если бы у каждого раунда были свои, как это называется, "раунд-тян", то у этого были бы такие:

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

thx

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

Problem description was nice (and short too) of your last contest ...

Hope it here also ... :)

»
10 лет назад, # |
  Проголосовать: нравится +26 Проголосовать: не нравится

Your previous contest's problems were awesome, looking forward!..

»
10 лет назад, # |
Rev. 13   Проголосовать: нравится -19 Проголосовать: не нравится

We HoPe gEt NeW RaTinG PoiNt aFTer tHiS CoNteST :) .GOOD LUCK eVerYoNe and thanks for this contest cgy4ever MikeMirzayanov Gerald ! (HaPPy NeW YeaR Chinese PeoPLe ;) )

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

А что за система Polygon??

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

»
10 лет назад, # |
  Проголосовать: нравится +18 Проголосовать: не нравится

Good luck everyone~ This must be a good contest! :)

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

Мне кажется или все пытаются набрать как можно больше "Вклада".

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

GL for every one

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

two contest in a day!
hard but fun! :D

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

Lack of div1 rounds didn't let div1 users refuse this contest!
1127 registrants for division 1!
Thanks for making this round a both division round ;-)

EDIT: 1144 after extra 10 mins!

»
10 лет назад, # |
  Проголосовать: нравится +93 Проголосовать: не нравится

Don't worry, the round delayed because of dinner on Petrozavodsk Training Camp :)

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

Funny. MikeMirzayanov says that the round is delayed because of dinner at Petr. Training Camp, and in the official post of the round, because of "technical reason". Or is the dinner the actual technical reason?

EDIT: already included above.

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

Wow! Is dinner a technical reason? :)

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

I want to rating under color of my eyes... (red) =D

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

sta-le-ar in gat mancarea

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

'technical'reason == dinner LOL :D

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

Extra time for "Codeforces Unavailable"?

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

Sorry for unstable work. It was a real stress test for server!

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

Как решать div2 D — div1 B?

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

    First we need to know how to calculate the number of different shortest paths from vertex 1 to vertex 2: it can be done by dp: dp[1] = 1, dp[v] = sum{dp[t] | dist(1,t) = dist(1,v) — 1}, then dp[2] is our answer.

    We need to do dp layer by layer. (first we consider vertexes have distance 1 to node 1, then vertexes have distance 2 to node 1 and so on.) So we can construct the graph layer by layer, and link edges to control the dp value of it.

    My solution is construct the answer by binary express: If k is 19, then we need some vertexes in previous layer such that the dp value is 16, 2 and 1. So we just need a way to construct layer with dp value equals to 2^k.

    In the first layer, it contains one node: 1, it has the dp value 1. In the next layer, we can construct 2 nodes, with dp value equals to 1. (We use [1 1] to denote it). And the next layer is [1 1 2], then [1 1 2 4], [1 1 2 4 8] and so on. So we need about 30 layers such that gets all 2^k where k < 30. It uses about 500 nodes.

    • »
      »
      »
      10 лет назад, # ^ |
        Проголосовать: нравится -57 Проголосовать: не нравится
      Комментарий удален по причине нарушения правил Codeforces
»
10 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

most of the solutions in problem B will fail, also my solution :( for k=10^9 n=1017

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

Давайте, что ли, сделайте какую-то систему пожертвований а-ля «Когда codeforces требуется вам, он к вашим услугам; а теперь codeforces нуждается в вас!». Может, хоть это устранит ужасные лаги в конце (почти) каждого контеста. Многие, наверное, пожертвовали бы n рублей, в сумме неплохо бы получилось :)

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

Great contest..Really enjoyed it Thanks alot

»
10 лет назад, # |
Rev. 4   Проголосовать: нравится +26 Проголосовать: не нравится


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

Питон в одной из посылок отображался как-то так, со сбитыми отступами. Поскольку это питон, читать это было печально.

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

good contest, good problems

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

When will the ratings be updated? UPD : Updated :D

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

Excuse me, I had an idea about the Div1 B/Div2 D. 1. If we add edges like this 1-3 1-4 2-3 2-4, then we' ll have 2 shortest paths, and 1-3 1-4 3-5 4-5 5-6 5-7 2-6 2-7 so that there' ll be4(2*2) paths, 8(2*2*2) paths with only 10 vertices... It seems that it' s easy to construct a graph with 2^n shortest paths. 2. If we devide the number k into a set of numbers which sum is k, and all the numbers must be 2^i( 0<=i<=32), then we can constuct a graph with paths I mentioned before. It is obvious that n won't be very large. Actually the problem can be solved correctly with this idea, but I' m so stupid that can' t work out

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

    your idea is correct,but you have mistake in your implementation also you are using more than 1000 nodes in the graph when binary representation of k contains more than 22 one

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

      Actually this idea uses much less than 1000 nodes, the powers of 2 that sum to 10^9 is the number of ones in the binary representation of k, and each power requires 2*i nodes which is a maximum of 2*32, so the total number of nodes is less than 2 + 32*2*32 << 1000. The problem is that dividing the paths into powers of 2 will have paths that are shorter than other paths requiring extra "dummy" vertices to equalize the paths.

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

      what is the easy solution in this way,please someone post how reduce nodes?

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

      Ohhh, yes. Thanks, I found my mistake. There will be about 1500 vertices when k is big enough...

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

    1-3 1-4 3-5 4-5 5-6 5-7 2-6 2-7

    How does this graph have 4(2*2) paths? I see only 2*2 paths.

»
10 лет назад, # |
  Проголосовать: нравится +23 Проголосовать: не нравится

2036 -> 2199 So close... Не заслужил видимо :)

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

thanks cgy4ever, you're the best :D

two excellent rounds, I'm looking forward to your third one :)

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

I got different outputs with same code, just one line difference at codeforces.

I get perfect output at my pc. Can anyone please explain why this happening? Got WA at problem B(div. 1), and get this problem by reducing lines of my code.

  • »
    »
    10 лет назад, # ^ |
    Rev. 7   Проголосовать: нравится -10 Проголосовать: не нравится

    I don't know why this happens, but may be it will be a useful fact that this code:

    #include <iostream>
    #include <cmath>
    using namespace std;
    
    int main(){
        int k,len;
        cin >> k;
        k = 1000000;
        len = (int)pow(1.*k,0.2);
        k -= (int)pow(1.*len,5.);
        cout << k;
        return 0;
    }
    

    gives same results whether "k = 1000000;" commented or not.

    Then, we can see that result depends on this:

    k -= (int)pow(1.*len,5.);
    

    If we don't use type conversion, we'll get different results, if use — the same anyway. But why? :)

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

      yes. Thanks. :)

      But beyond type conversion, my code is only depend on whether k = 1000000 is commented or not. But, WHY???

      • »
        »
        »
        »
        10 лет назад, # ^ |
        Rev. 8   Проголосовать: нравится -8 Проголосовать: не нравится

        Finally, I think, the reason is that len*len*len*len*len != pow(len,5.));

        You can check it easily by cout << ((1.*len*len*len*len*len)==pow(len,5.));

        Another question is why they're not equal. And how it depends on way of assining 1000000 to k.

        Oh, of course, this stuff happens only wiht GNU. MSVS works well with all these cases.

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

          My g++ version is 4.6.3 and two version of my code outputs correctly. Ideone runs g++ 4.8.1 which also outputs 240625. you can check it here

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

    MikeMirzayanov, With due respect, will you check it, please??

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

      pow function returns double type result, (not int), so that the floating-point error could be happened. This behavior happened because of you, not server.

      You can reduce the error by using int(pow(len,5.)+0.5) instead of pow(len,5.).

      • »
        »
        »
        »
        10 лет назад, # ^ |
        Rev. 2   Проголосовать: нравится -11 Проголосовать: не нравится

        Once I change //k = 1000000 this line, server is calculating in another way? HOW? How pow(len, 5) produce different result on same server when k is injected value manually?

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

          Pow arguments will be automatically casted into double, so there is no difference between int arguments or floating-point number arguments.

          If len is enough small, Pow(len,5) can still return wrong result. Why? Example, len=10. Your expectation is 100000, but the function could return 99999.99999. Because you wrote: int(pow(len,5)), 99999,9999 will be casted and became 99999.

          I don't know how statement k=1000000 affected to pow function. Your problem is not in this statement, you need to use more safe power function. Built-in pow function doesn't work too fast, and if arguments are enough large, errors will be caused surely.

          If you still want to use pow and other function returning floating-point result, when you cast, you must write something like this: n = int(f(x)+0.5).

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

    "Problems with floating point numbers — the most often reported non-bug". GCC usually use wider floating-point types to compute expressions that can be computed at compile-time, which is permitted by C++ standard.

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

Хотел придумать смешной комментарий, но не смог.

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

Great contest for me... there were short description to make me known quickly what actually problem wanted...

And the translation was awesome.... easy to understand...

I'm really waiting for your next contest... :)

Great ... Hats off ... :) cgy4ever

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

cgy4ever if possible prepare contest regularly , you are totally awesome . All problem setters should learn from you how to make an interesting round :D

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

So stupid mistake in problem div2 B. I'll never submit code without some own tests.I'll never submit code without some own tests.I'll never submit code without some own tests.I'll never submit code without some own tests.I'll never submit code without some own tests.I'll never submit code without some own tests.I'll never submit code without some own tests.I'll never submit code without some own tests.I'll never submit code without some own tests.

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

    A better phrase:

    I will never submit a code without some own tests as long as my programming intuition is not on its heights.

»
10 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится
»
10 лет назад, # |
  Проголосовать: нравится -8 Проголосовать: не нравится

I'm sorry, but I can't find what is wrong with my code for Problem C Div1 Submission:5886576 I'm trying to find the card with maximum number one can take ( in each step ) Is there something wrong in my implementation or....?

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

How comes the Dp relation in Div2 Problem D that dp[v] = sum{dp[t] | dist(1,t) = dist(1,v) — 1}? I am not able to get it. Could someone please explain?

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

    If we have dk - 1[v] which contains the count of the shortest paths with length k - 1 from some s vertex to another vertex then it is easy to get the count of the shortest paths with length k.

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

I think that test 7 in the problem B is wrong. Can anybody explain me?

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

Awesome round! I was Candidate Master before but now I am Master. At a point I was on the 7th place with A and C, and that felt really great. However, I couldn't maintain that wonder, but still, great problems and great round!

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

Ваши контесты заставляют подумать!и мне это очень нравится)

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

Congratulations! codeforces, I appreciate everything that you have done for us. we're gonna have to work together here!