Zlobober's blog

By Zlobober, 7 years ago, translation, In English

Hi everybody,

Today there will be the first day of Moscow Open Olympid, that is the personal programming competition that is held in Moscow each spring. This contest is prepared by Moscow Olympiad Scientific Committee that you may know by Moscow Team Olympiad, Moscow Olympiad for Young Students and Megapolises Olympiad (rounds 327, 342, 345, 376, 401, 433, 441, 466).

Open Olympiad consists of the most interesting and hard problems that are proposed my a wide community of authors, and that is why we decided to give you an opportunity to crack the complete problemset of the contest by making some kind of an experiment. Tomorrow we are going to conduct a rated Codeforces round based on problems of both days of our Olympiad.

We kindly ask all the community members that are going to participate in the competition to show sportsmanship by not trying to cheat in any manner, in particular, by trying to figure out problem statements from the onsite participants. If you end up knowing some of the problems of Moscow Open Olympiad (by participating in it, from some of the onsite contestants or in any other way), please do not participate in the round. We also ask onsite contestants to not discuss problems in public. Failure to comply with any of the rules above may result in a disqualification.

Round will happen at 11:05, March 9th, Moscow time and will last for 2.5 hours. There will be 6 problems in each division.

Round problems were prepared by ch_egor, Sender, Flyrise, cdkrot, malcolm, vintage_Vlad_Makeev under supervision of your humble servant with a great help of meshanya, GlebsHP, Endagorion and Helen Andreeva. Some of the div2 problems were finalized with help of Codeforces team represented by fcspartakm, also we would like to thank round coordinator KAN for his help in deciding which problems to take and all the discussions.

Good luck everybody!

UPD: Announcement email contained incorrect start time. Instead of "12:05, March 9th, Moscow time, 2 hours" it should be "11:05, March 9th, Moscow time, 2.5 hours", as was originally in the round announcement.

UPD2: Round is postponed by 10 5 minutes. Stay tuned :)

Congratulations to the winners!

Division 1:

  1. dotorya
  2. Swistakk
  3. Syloviaely
  4. zscoder
  5. dreamoon_love_AA
  6. SkyDec
  7. Marcin_smu
  8. yutaka1999
  9. Kostroma
  10. Will_Dearborn

Division 2:

  1. _ChenKerui
  2. Demerzel_IV
  3. 879333752
  4. yyc_jm
  5. Anson529
  6. iotang
  7. wcz112
  8. Hankpipi
  9. cyz666
  10. wwd2075

UPD3: Finally, the editorial is there! Kudos to vintage_Vlad_Makeev and ch_egor for making it appear in a text form.

  • Vote: I like it
  • +236
  • Vote: I do not like it

| Write comment?
»
7 years ago, # |
  Vote: I like it -142 Vote: I do not like it

Very bad time plz extends start time..

  • »
    »
    7 years ago, # ^ |
    Rev. 2   Vote: I like it -95 Vote: I do not like it

    True,inappropriate for indian users

    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it +106 Vote: I do not like it

      Codeforces is an international site for all people.

      Not only indians

    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      This is an international website. Not only work for you.

      Different times are good for different users.

»
7 years ago, # |
Rev. 4   Vote: I like it +26 Vote: I do not like it

The time is right for Chinese students! That's great!

UPD: The Problem was fixed, and wish everyone will increase your rating.

  • »
    »
    7 years ago, # ^ |
    Rev. 2   Vote: I like it +20 Vote: I do not like it

    Maybe we should say "Perfect time for Asian users" :P

    (Although I found that I have to skip some classes just now if it actually begins at 16:05, March 9th, UTC+8...qwq...)

    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it +4 Vote: I do not like it

      Not sure if perfect for all of us, as some (including me) still have school during the time.

      Now I have to decide on whether to do contest or to attend class (most likely I won't :p )

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +14 Vote: I do not like it

    The time in the blog is the correct one, it is same on the contests page and in the blog now.

»
7 years ago, # |
Rev. 6   Vote: I like it 0 Vote: I do not like it

Will this round happen at 11:05, March 9th, Moscow time? But in CONTESTS, it will start at 12:05, March 9th, Moscow time. When can I enjoy it? (sorry for my poor English :(

UPD: Maybe Johnson_sky found another difference?

UPD2: The Problem was fixed. Wish everyone have fun.

  • »
    »
    7 years ago, # ^ |
    Rev. 3   Vote: I like it +7 Vote: I do not like it

    The time I showed was UTC+8, so I didn't notice the difference in the start time.

    • »
      »
      »
      7 years ago, # ^ |
      Rev. 2   Vote: I like it +18 Vote: I do not like it

      utf-8 ? Do you mean UTC+8 ?

      In the blog, 11:05, March 9th, MSK == 16:05, March 9th, UTC+8 .

      But in the CONTESTS, it is 17:05, March 9th, UTC+8 .

      Obviously, they are different.

      And thanks for that you found another difference.

      UPD: The problem is fixed.Have fun.

»
7 years ago, # |
Rev. 2   Vote: I like it +6 Vote: I do not like it

I don't know if I should skip the math class tomorrow to participate in this contest.

PS: Now it coincide with my midterm exam...

»
7 years ago, # |
  Vote: I like it +19 Vote: I do not like it

I hope this contest can help my rating increase to 2000+

»
7 years ago, # |
  Vote: I like it +5 Vote: I do not like it

Perfect time for some Asian OIers...At least for me...

»
7 years ago, # |
Rev. 3   Vote: I like it +4 Vote: I do not like it

Never experienced this exciting feeling before.I like these competition.Newer fighting!

»
7 years ago, # |
  Vote: I like it +4 Vote: I do not like it

I have lessons at 14:00(UTC+8) and it will lasts for 2.5 hour. So I can take part in this round if it will start at 17:05(UTC+8) but it moves to 16:05.... how disappointing.

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    You will miss the chance to go to Div 1. xd

»
7 years ago, # |
Rev. 2   Vote: I like it +5 Vote: I do not like it

Perfect time for Asian users!

Nope! It seems to be Dinner time...

»
7 years ago, # |
Rev. 2   Vote: I like it +52 Vote: I do not like it

Something is wrong here. Originally it was 12:05. I also remember checking the time in the contest tab. Also in email it was mentioned 12:05 and now you are moving the whole contest by one hour just because you wrote this in the announcement?

First thing is that you should not move it. Announcement could be easily adjusted. Perhaps very few people clicked the url with time in this announcement. It is also a very short time for such a change.

Second thing is that you should send at least one more email with the correction. Why do you assume that everybody regularly checks main cf website instead of their email?

This round is already in an unusual time. If you won't make sure that everybody is informed about the change, the participation level may be very low but the frustration very high as a lot of people will appear here at 12:05 to discover that contest will have been running for an hour already...

  • »
    »
    7 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Agreed. If it was postponed that might be acceptable but now many will turn up too late for the contest.
    Lucky I happened to check this post once before going offline right now or I would have missed it too.

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +48 Vote: I do not like it

    I check cf more often than e-mail.

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +22 Vote: I do not like it

    Sorry, my fault. I found that the times changed just before a long train trip. I decided that the announcement in the post + the note in a registration form are enough. During the train trip I was out of Internet without any chance to send extra emails.

    • »
      »
      »
      7 years ago, # ^ |
      Rev. 2   Vote: I like it -12 Vote: I do not like it

      I guess your train trip is over. So why you still haven't sent the notification?

      • »
        »
        »
        »
        7 years ago, # ^ |
          Vote: I like it +18 Vote: I do not like it

        It finished ~30 minutes ago (I've sent the previous message from the train via phone). Anyway it takes 2-3 hours to send emails.

        • »
          »
          »
          »
          »
          7 years ago, # ^ |
            Vote: I like it +33 Vote: I do not like it

          I see. Just in case, I didn't mean to be offensive. Thank you for all that you are doing for CodeForces!

»
7 years ago, # |
  Vote: I like it +1 Vote: I do not like it

i will participate,when ever, what ever happend..

  • »
    »
    7 years ago, # ^ |
    Rev. 2   Vote: I like it +13 Vote: I do not like it

    my laptop battery is empty due to power outage for more than 12 hours now... wind storm cut Power cables .. so I did not participate. my luck ..

»
7 years ago, # |
Rev. 2   Vote: I like it +24 Vote: I do not like it

I'm really thankful to Zlobober and MikeMirzayanov for one more CF contest.Good luck for everyone.Only high ratings. :)

»
7 years ago, # |
  Vote: I like it +12 Vote: I do not like it

My score around the 1590 some times,hope I can overstep 1600,good luck to everybody!

  • »
    »
    7 years ago, # ^ |
    Rev. 2   Vote: I like it +9 Vote: I do not like it

    I can't overstep 1600 again,so sad.final test C is wrong answer.God always jokes me.......I must be overstep in tomorrow

»
7 years ago, # |
  Vote: I like it +52 Vote: I do not like it

Delay :|

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +21 Vote: I do not like it

    To increase the participation btw less participation this time :(

»
7 years ago, # |
  Vote: I like it +5 Vote: I do not like it

Postponed by 5 minutes... You really want to confuse people...

»
7 years ago, # |
  Vote: I like it +5 Vote: I do not like it

"UPD2: Round is postponed by 10 minutes. Stay tuned :)"

it only says 5 on contest page

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it
UPD2: Round is postponed by 10 minutes. Stay tuned :)

*5 minutes

»
7 years ago, # |
Rev. 2   Vote: I like it +14 Vote: I do not like it

Fun contest! Enjoyed the problems, especially Div 2 D and E (Div 1 B and C).

  • »
    »
    7 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    is there anything to do with MST in div2E

    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      No, there is no MST

      There is Strongly connected components of directed graph.

      But I'm not sure if my solution correct or not. But pretests were passed

  • »
    »
    7 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    How did you solve E?

    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it +27 Vote: I do not like it

      Didn't solve it in time, but I think I had the right idea.

      Basically, you create a dependency graph. That is, the vertices in the graph are the datacenters, and you draw an edge from datacenter A to datacenter B if bumping A's time an hour would force you to bump B's time as well. (That is, if an item x is stored in A and B, and B's time is the hour directly after A's time.)

      Then, the problem boils down to: I want to find the vertex in this graph, for which, if I pick it, the number of vertices that I am therefore forced to pick is the smallest possible. (In terms of the graph, this means that I want to pick the vertex v, who can reach the fewest number of other vertices.)

      So, we can observe that in any dependency chain, or dependency tree, or dependency DAG, we can always just pick some datacenter at the end of the dependencies — i.e. some datacenter, which might have edges coming into it, but no edges coming out. Then, if we pick that guy, we aren't forced to pick anyone else. So our answer is 1.

      However, if there are cycles, then it's trickier. If a vertex is part of a directed cycle, then we can't just pick a vertex at the "end of the chain", since there is no end of the chain. Picking any vertex (datacenter) in that cycle forces us to take EVERY vertex (datacenter) in that cycle. More generally, taking any vertex in a strongly-connected component implies that we have to take the whole SCC. So, the problem then boils down to: we want to pick the smallest SCC that has no outgoing edges. We can use Tarjan's or Kosaraju's to get the SCCs of the graph, and then find the smallest SCC with no outgoing edges.

      • »
        »
        »
        »
        7 years ago, # ^ |
          Vote: I like it +3 Vote: I do not like it

        good explanation , I was thinking like what happens if chain length is more than h then it would be contradicting but if chain length is more than h then it wouldn't form a cycle .

»
7 years ago, # |
  Vote: I like it +10 Vote: I do not like it

Hacks?

»
7 years ago, # |
  Vote: I like it -54 Vote: I do not like it

我是中国人

»
7 years ago, # |
Rev. 2   Vote: I like it +8 Vote: I do not like it

Hmm... does anyone know about pretest 9 of Div1A/Div2C and Div1C/Div2E?

  • »
    »
    7 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Can anyone give the full solution of E? Mine had something to do with the minimum sized SCC of the induced hour-based graph but failed on pretest 4.

    • »
      »
      »
      7 years ago, # ^ |
      Rev. 2   Vote: I like it +3 Vote: I do not like it

      I basically did SCC, and then you know that SCCs make a DAG, so you find the vertex with out-degree 0 in the DAG that has the smallest SCC size.

      Note: SCCs are of the graph where (v, w) is an edge if (v, w) share some data and (u[v]+1)%h = u[w]

    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I did same and my code failed on pretest 5

    • »
      »
      »
      7 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      My solution is also based on SCC as well. I used Tarjan's Algorithm to have the SCCs sorted topologically.

      Anyway, it seems like I know what I did wrong, but I'm not so sure (since I couldn't find for myself any cases to prove it). If I was right, the mistake was in my way to choose the correct minimum-size SCC to answer.

  • »
    »
    7 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    My original code for Div1C/Div2E got WA on Pretest 9 and I found a bug. For the test:

    5 6 4

    3 2 1 0 3

    5 4

    4 3

    2 3

    2 5

    2 4

    1 4

    My code would say the answer is 5, but the answer is 4 (just take 2, 3, 4, and 5). I don't know if yours also failed the same way, but the main idea was that cycles broke my initial algorithm.

    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Well sadly mine returned the totally correct answer. Should be another case...

  • »
    »
    7 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    My first wrong solution failed on 9-th pretest. The antitest for the solution was:

    00110100
    

    One of the correct answers is:

    2
    5 1 3 5 6 7 
    3 2 4 8
    

    When mine output -1. Check yours, hope it is what you search for.

    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Thanks, but my solution won't fail this test. It returns:

      2
      3 1 3 8
      5 2 4 5 6 7
      
      • »
        »
        »
        »
        7 years ago, # ^ |
          Vote: I like it +5 Vote: I do not like it

        may be it may help. 01001010 answer: 2 7 1 2 3 5 6 7 8 1 4

        • »
          »
          »
          »
          »
          7 years ago, # ^ |
            Vote: I like it +3 Vote: I do not like it

          Yes, my solution failed on this one. Thanks ;)

  • »
    »
    7 years ago, # ^ |
    Rev. 2   Vote: I like it +5 Vote: I do not like it

    It is just 000111000111...111000 (block with len 3 repeated 66665 times).

    • »
      »
      »
      7 years ago, # ^ |
      Rev. 2   Vote: I like it -8 Vote: I do not like it

      Can you clarify more? Are they 66665 three-digit blocks alternating?

      And the answer isn't -1, right?

      • »
        »
        »
        »
        7 years ago, # ^ |
          Vote: I like it +5 Vote: I do not like it

        (000)(111)(000)(111)(000)...(111)(000)

        Answer is yes.

      • »
        »
        »
        »
        7 years ago, # ^ |
          Vote: I like it +5 Vote: I do not like it

        You can see that one of the answers is 3-sequences length 66665: 0101010...01010

      • »
        »
        »
        »
        7 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Ouch, I understood my mistakes now. Perhaps I should redesign another approach for this problem.

        Thank both of you, ch_egor and nikich340 for helping me out! ;)

        • »
          »
          »
          »
          »
          7 years ago, # ^ |
            Vote: I like it +6 Vote: I do not like it

          Yes, your answer output -1 on short version of that test:

          000111000111000

»
7 years ago, # |
  Vote: I like it +11 Vote: I do not like it

bad explanation for B div2 :|

»
7 years ago, # |
  Vote: I like it +14 Vote: I do not like it

Div2B statement is horrible.

»
7 years ago, # |
  Vote: I like it +3 Vote: I do not like it

How to solve Div2 D?

  • »
    »
    7 years ago, # ^ |
    Rev. 2   Vote: I like it +11 Vote: I do not like it

    Yes, I saw that 549 passed it and feeling that I'm a bit stupid :P

    I managed to solve only the inverse task (find final position of some number).

    • »
      »
      »
      7 years ago, # ^ |
      Rev. 2   Vote: I like it +12 Vote: I do not like it

      Here's a kind of hand-wavy explanation

      The optimal strategy is to always move the rightmost number.

      If you simulate a decently sized example (like n=8), you can note that essentially every odd-indexed number stays where it is, and there's a steadily-moving contiguous "blob" of numbers moving from the right to the left.

      Given an index i, we want to find out the index that it originally came from. To do this, first, let's try to find the index that it came from on its most recent jump. Let's say n=8, and we're looking at index 4 (using the 1-based indexing in the problem). (I highly recommended drawing out this example and simulating it. If you've done that, you'll see that the number that ends at position 4 is 7. So we want to find out where 7 was before its last jump.)

      Every jump that takes place is of the following form: it's a number leapfrogging from the right of the blob/train to the left. And it's leapfrogging over ALL the numbers in the trainblob.

      So, if we can figure out how big the blobtrain was at that point in time, then we can figure out how far our number leapt to get to where it is now. Well, we can note that every number that started to the left of index i has not moved yet. And, every other number besides those must be part of the train. So, the amount of numbers in the train is n — numbers_to_the_left_of_i.

      By examination, we can see that there are i/2 numbers to the left of i. So, the amount of numbers in the train that 7 leapfrogged over was n — i/2 = 8 — 2 = 6 (including itself). So the position that it came from was i + (n — i/2). And before the 7 was at that previous position, we can calculate its previous-previous position in the same way. We can iterate that i = i + (n- i/2) calculation until i is odd, which is its starting place. And the value of the number at a given position p is (p+1)/2

      edit: Tl;dr read xiaolongbao's comment

    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      How do you do the inverse task?

      • »
        »
        »
        »
        7 years ago, # ^ |
        Rev. 2   Vote: I like it +3 Vote: I do not like it

        I found position differences for all numbers in small array(8, for example) and find the next pattern:

        1: []
        2: []
        3: []
        4: []
        5: [7]
        6: [5]
        7: [3, 6]
        8: [1, 2, 4]
        

        So, initial position for number x is a = 2x - 1, initial position difference is k = 1 + 2(n - x), which doubled on each iteration. Reduce number position while we can do it.

        int get_pos(int x) {
           int a = 2*x - 1;
           int k = 1 + 2*(n - x);
           while (a - k > 0) {
              a = a - k;
              k = k * 2;
           }
           return a;
        }
        return k;
        
    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Same with me .

  • »
    »
    7 years ago, # ^ |
    Rev. 4   Vote: I like it +8 Vote: I do not like it
    lint getAns(lint now){
        if(now % 2 == 1){
            return (now + 1) / 2;
        }else{
            lint x = n - (now / 2) + now;
            return getAns(x);
        }
    }
    

    that is all, if u still have problem can reply me

    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      any logic explanation?)

      • »
        »
        »
        »
        7 years ago, # ^ |
        Rev. 7   Vote: I like it +10 Vote: I do not like it

        u can see the kwangg's explanation. it's very detailed

        now, i explain my code

        it's obvious that if the num which less than n/2 will fixed

        for example n = 6:

        1_2_3_4_5_6 -> 142635
        

        1 and 2 and 3 is fixed

        so

        if(now % 2 == 1){ return (now + 1) / 2;}
        

        if u wanna find the ans of position 4

        1_2?3_4_5_6
        

        when a number will go to position 4 , you can know that there is no space in the back of position 4, and the number which position is 8 will go to position 4, so u just need find the number which will go to position 8, then recursion.Until the beginning, there is a number in this position. Obviously, at the beginning, the number must be in the odd number.

        lint x = n - (now / 2) + now;
        return getAns(x);
        
»
7 years ago, # |
  Vote: I like it -9 Vote: I do not like it

I belive that everybody wrote this contest right.

»
7 years ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

Anybody initially stuck on test case 9th of (Div2 C/ Div1 A) and then later able to successfully surpass that??

I m still getting WA on 9th test case :(

  • »
    »
    7 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Yes. Though I was stuck in this case for only 5-10 minutes, still this might help. First of all, the test case is 000111000111000...000 for 66665 times. The length really doesn't matter, the shorter version f this input is 000111000111000. What you may have done wrong is that you may haven't considered detecting 01010 type of strings with multiple 1's. In other words, this test case is the combination of 0101010 (long zebra string) and 001100 (overlapping zebra string). I handled each of them separately, but test 9 got me. Got AC after correcting this bug. I hope this helps.

  • »
    »
    7 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    A straightforward implementation of Div1A/Div2C using sets passes.

    See this http://mirror.codeforces.com/contest/950/submission/36136531

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

anything special about test 15 in F? And should there be answer YES or NO?

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +18 Vote: I do not like it

    Just some random test with answer "Yes" and n = 2600.

    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Anything special about test 7 :D?

      • »
        »
        »
        »
        7 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Small manual test.

        2
        -1000000 0
        1000000 0
        0 -1000000
        0 1000000
        
        • »
          »
          »
          »
          »
          7 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Duh, I got WA on it because of overflows and I lacked few seconds to submit version with define int long long which already passes this test. I hope that my final version will not get AC (I think it won't), otherwise I can be declared incredible loser :P.

»
7 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Can anybody please explain the complexity of my code for problem Div2 C. I think it will fail system test.

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Div 2 D?

  • »
    »
    7 years ago, # ^ |
    Rev. 2   Vote: I like it +30 Vote: I do not like it

    If you're looking at an odd index, print the number that was there originally, i.e. (i + 1) / 2.

    Otherwise, assume that that location is currently the rightmost blank not filled in. For example, with N = 7, if we're looking at index 4:

    1_2_37465

    The number which will occupy the second blank is equal to the rightmost number in the current list. There are no blanks to the right of index 4, and there are 2 numbers to the left of index 4. In general, there are i/2 numbers to the left of a blank. Thus, there are N - i/2 numbers to the right, and since they're all filled in, we can say that the answer for index i is the same as the answer for i + N - (i/2).

    code
»
7 years ago, # |
Rev. 2   Vote: I like it +16 Vote: I do not like it

Two identical codes with just reformatting from Mo2men and Molo5ya.

Here are the submissions: 36101349 and 36100512.

  • »
    »
    7 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    all coders using two pointer -_-

    • »
      »
      »
      7 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      Just a joke, nevermind.

    • »
      »
      »
      7 years ago, # ^ |
      Rev. 3   Vote: I like it +4 Vote: I do not like it

      That's obviously cheating and anyone who can think can catch it.

      btw, here are 2 more submissions from the last edu round 36010393 and 36017149.

      We aren't robots, we can think and decide wisely :))

      • »
        »
        »
        »
        7 years ago, # ^ |
          Vote: I like it +5 Vote: I do not like it

        Nice try, easy problems and two persons have the same training in the university and in the same team in ECPC, not so weird :P, focus on your local training/ranking plz

        • »
          »
          »
          »
          »
          7 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Please, let's face ourselves with the truth.

          I swear I'm doing this just for Mo2men, he is getting better, but with that way he will never be great, Also I know him personally.

          • »
            »
            »
            »
            »
            »
            7 years ago, # ^ |
              Vote: I like it +4 Vote: I do not like it

            thanks, my mentor will focus on that :P

»
7 years ago, # |
  Vote: I like it +37 Vote: I do not like it

Oh boy..

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Idea for div2 E?

»
7 years ago, # |
Rev. 9   Vote: I like it +64 Vote: I do not like it

Congratulations zscoder !

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +61 Vote: I do not like it

    Thanks for the wish :)

    • »
      »
      »
      7 years ago, # ^ |
      Rev. 3   Vote: I like it +23 Vote: I do not like it

      I get motivated by your rating graph. I also showed my friends. This is what never give up. Congratulations...

      I am a newbie and I feel sad. I know much more thing but in contest 1-2 problem-solving.After the contest I have done the problem but problem in the contest. Please give me some suggestions so I can improve my coding skill. I am waiting.....****

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +27 Vote: I do not like it

    I also congratulate to Yuta yutaka1999 Takaya for being legendary grandmaster!

»
7 years ago, # |
  Vote: I like it +3 Vote: I do not like it

How the hell could this guy jackichul solve D just 3 mins after E? And his solutions of D and E also had different style from A, B and C.

  • »
    »
    7 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    1. She/He may have seen this problem earlier and simultaneously thought about D and E and/or C or anything. I can guess because I did the similar thing too, only for 10-15 minutes though.
    2. Also, this Div2 D problem was too easy. I solved it in under 8 minutes, though the contest page won't show that because, as I said earlier, I was busy debugging my C problem at the same time. So, yes, it could be done in 3 minutes, not impossible. A bit surprising, but nothing odd. I hope it clears your confusion.
»
7 years ago, # |
  Vote: I like it +1 Vote: I do not like it

36111831 can anyone help me to find out the runtime error??? TIA

»
7 years ago, # |
  Vote: I like it +3 Vote: I do not like it

That feeling, when you realize your solution is wrong and you know how to fix it :) But you had already locked the problem...

»
7 years ago, # |
  Vote: I like it +83 Vote: I do not like it

»
7 years ago, # |
  Vote: I like it +24 Vote: I do not like it

How to lose 10 places for nothing:

Write endl instead of '\n' in B, but pass pretests anyway. Panic and resubmit.

»
7 years ago, # |
  Vote: I like it -34 Vote: I do not like it

Hello Sir. What is intended solution for problem div1. F. My friend from Russia say that author solution is . Is it true? KAN ch_egor Sender Flyrise cdkrot malcolm vintage_Vlad_Makeev meshanya GlebsHP Endagorion

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +10 Vote: I do not like it

    Is it true?

    No. Author's solution is O(n2). Stay tuned for the editorial.

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    My solution (that should be quadratic on a random instance) gets TL on test case 17. Not surprisingly.

»
7 years ago, # |
  Vote: I like it +3 Vote: I do not like it

What is wrong with the 55th test case in problem Div.2E/ Div.1C?

  • »
    »
    7 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Most of my friends using Tarjan get WA, while those using Kosaraju not. Wondering too.

»
7 years ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

q

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Div1D/Div2F solution?

»
7 years ago, # |
Rev. 3   Vote: I like it +13 Vote: I do not like it

How to solve problem Div 1 D ?

My idea is as follows -

  • From the initial arrangement, greedily try to send right half ( = n/2 * b) of the students towards right. And remaining towards left.

  • At any instant, when first instructor is at room i. All students till room (d + 1) * i can reach to the room. So at moment we know maximum how many students can reach room i. Call this lsum. Also, let's keep track of how many students are are locked in rooms with room number less than i, call this lused.

  • Now if lsum - lused >= b we will lock b of them in current room. And conceptually push remaining to next room, i+1. After this, lused += b.

  • If lsum - lused < b we will lock lsum - lused of them in current room. In this case we increase counter, c1 += 1 indicating this will be reported by the instructor.

  • Similarly we will proceed from right side, (left and right both proceeding simultaneously).

  • In case of odd n, simply ignore the middle room. Because it will always have >= b students.

  • Implementation wise, I am moving two pointers l and r so compute the lsum and rsum for each i. Code 36115092

Where am I going wrong ?

Update : Nothing is wrong with this solution. Fixed implementation issue. Correct code 36121095

  • »
    »
    7 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I guess this If lsum - lused < b we will lock lsum - lused of them in current room. In this case we increase counter, c1 += 1 indicating this will be reported by the instructor. is wrong.

    By comparing your code, you can find it is better to let lsum - lused go to right room instead of lock them when lsum - lused < b

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

How do we solve Div2C fast? I tried 3 times and got TLE on test 8 for all 3 tries ... Can anyone give me hints or ideas?

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +2 Vote: I do not like it

    You can keep the basic idea from your solution.

    The reason why you get TLE is because you spend so much time searching for the next index i (O(n) in the worst case). You can find the index in O(1) time, if you keep track of the arr[i] which end in 1, and the arr[i] which end in 0. You can use two stacks/queues ending_in_zero and ending_in_one which store the indices.

    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Wow thank you very much that was very clear to understand.

      Just out of curiosity, how did you find my submission?

      • »
        »
        »
        »
        7 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Your profile -> Submissions

        • »
          »
          »
          »
          »
          7 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Oh I didn't know I could view other people's submissions.. thanks!

    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      But, what would I maintain a set?

    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      36120744 Time Limit :'( How can i reduce my complexity ? How should i do to ignore erase function ? please ,help :)

      • »
        »
        »
        »
        7 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        u can use two stacks, one for keep track of the index of the sequence where 0 is the last element and other for 1...

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Perfect time for Chinese users!

»
7 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

I had solved Div 2 C in paper, but I couldn't implement that. My solution was something like: If first element is 1, then obviously output  - 1, so assume the first element is 0. Now create a string S0 and set S0 = 0. Now read of the digits after the first digit one by one: (a) If it's 0, then if there's a string Sj ending with 1, add 0 to that string, or if they don't exist, create a new string Si = 0 and keep track of it. (b) If it's 1, then if you can find a string Sk ending with 0, then add it to the end of that, otherwise if you can't find output  - 1. Add the end, output the elements which form your strings one by one in each line.

Now the reason I couldn't implement is that I couldn't figure out how you're supposed to keep track of the strings and the array indexes which create the string without creating an 200000 by 200000 array ? How you do that ?

  • »
    »
    7 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Why would you need a 200000 by 200000 array to track the strings? You could maintain two lists of strings, one for the strings ending with zero and another list for the strings ending with one. You should be able to pick the a string from one list and move it to the second list in constant time.

    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      OK, but how do you maintain a list of lists without knowing what will be the size of either one after the algorithm runs ?

      • »
        »
        »
        »
        7 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        you can use 2D vector for that case

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

What was the test case #8 in the problem Div 1 A? I have tried running my code on a lot of possible test cases and I am not able to find a test case that can cause a runtime error. I have even put an infinite loop to get a TLE in all possible situations where I might get a runtime error. Any help with it?

  • »
    »
    7 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Your code get RTE when the input is a string of length n = 199998 such that - first n/3 chars are '0' and last n/3 chars are '0' and everything in between are '1'.

    Tested on custom invocation. Btw, why use goto ?

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +6 Vote: I do not like it

    The error is because of order of line 44 and line 45.

    vals[0].erase(*it);
    pos = *it;
    

    When you erase from the set, the iterator it may have changed. Infact, the earlier it may already have been dumped (free) and is hanging. And you are de-referencing that to assign value in pos.

    This can be fixed easily if you reverse the order of those two lines. I hope, its helpful :)

    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it +5 Vote: I do not like it

      OMG, wasted entire contest in finding this error. It was not triggered on my system upon generating so many tests. Thanks a lot for the help :)

      I used goto because while writing code, I thought that there will be many places from where I will go to DONE, but turned out there were not much. In retrospect, I should have removed that and replaced it with another break statement.

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Where is the Editorial? :(

»
7 years ago, # |
  Vote: I like it +49 Vote: I do not like it

Hi everybody!

Thanks again for participation, we were really busy with the awards ceremony of the onsite round here in Moscow and I've literally only got back home from the Olympiad.

The editorial will appear tomorrow, we were not fast enough to prepare a well-written text editorial for the round yet.

»
7 years ago, # |
  Vote: I like it +217 Vote: I do not like it

Maybe that will look more like bragging but I consider this funny enough to point this out.
I already:
1. Took 2nd place on Codeforces
2. Took 2nd place on TopCoder
3. Took 2nd place on AtCoder
4. Took 2nd place on CSAcademy
5. Took 2nd place on Hackerrank
6. Took 2nd place on ACM ICPC WF
but I never won any of these xD.

Moreover in high school biggest deals for me were Polish and international olympiads in math and informatics and I:
1. Took 2nd place in PMO
2. Took 2nd place in POI
3. Got silver medal on IMO
4. Got silver medal on IOI
Already at that time I received nickname "silver human" and it seems I proudly continue to follow this path.

»
7 years ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

Still waiting for the Editorial...
BTW, div.2 E has so many test cases...
But finally I got Accepet, yeah!

»
7 years ago, # |
  Vote: I like it +8 Vote: I do not like it

Just a final update: the great editorial by vintage_Vlad_Makeev and ch_egor is there, be sure to check it out.

See you in next Codeforces Round in cooperation with Moscow Olympiads!

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Please someone help why am i getting TLE in ques C

http://mirror.codeforces.com/contest/950/submission/36191394

thank you

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it
    x = lower_bound(s1.begin(),s1.end(),f);
    

    It works in linear time for std::set.

    "On non-random-access iterators, the iterator advances produce themselves an additional linear complexity in N on average."

    Use

    x = s1.lower_bound(f);
    
»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Hi, I have a question. Why the verdict of my submission says "TIME_LIMIT_EXCEEDED" even when I am able to see the "participant's output". Here is my submission. http://mirror.codeforces.com/contest/949/submission/39421261

Thanks.

  • »
    »
    7 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    You took TL during output.

    • »
      »
      »
      7 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      How can it display my answer if my answer has exceeded time limit

      • »
        »
        »
        »
        7 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        It is collect your output all time, but when something going wrong, it is stop, and it show verdict, and output(not full).