MikeMirzayanov's blog

By MikeMirzayanov, history, 5 years ago, In English

I almost copied my previous blog post to separate two discussions: about Div. 4 in general and about Round 640. Please, visit this blog post to discuss Div. 4 rounds.

Hello Codeforces!

Yes, it is not a mistake I decided to run the first Div. 4 round: Codeforces Round 640 (Div. 4)! It starts on May/09/2020 17:35 (Moscow time).

The format of the event will be identical to Div. 3 rounds:

  • 5-8 tasks;
  • ICPC rules with a penalty of 10 minutes for an incorrect submission;
  • 12-hour phase of open hacks after the end of the round (hacks do not give additional points)
  • after the end of the open hacking phase, all solutions will be tested on the updated set of tests and the ratings recalculated
  • by default, only "trusted" participants are shown in the results table (but the rating will be recalculated for all with initial ratings less than 1400 or you are unrated participant/newcomer).

I urge participants whose rating is 1400+ not to register new accounts for the purpose of narcissism, but simply to take part unofficially. Please do not spoil the contest to the official participants.

Only trusted participants of the fourth division will be included in the official standings table. This is a forced measure for combating with unsporting behavior. To qualify as a trusted participants of the fourth division, you must:

  • take part in at least two rated rounds (and solve at least one problem in each of them),
  • do not have a point of 1600 or higher in the rating.

Regardless of whether you are a trusted participant of the fourth division or not, if your rating is less than 1400 (or you are a newcomer/unrated), then the round will be rated for you.

Please, read some of my thoughts about the problems of this round:

  • Don't expect A+B level problems :-) It is a real contest with easy but problems. I hope most problems fit in range D3A-D3D problems.
  • I'm not sure about order of problems. Try to read all problems or at least most of them. Testers expressed skepticism about the order of the problems but suggested different pairs of problems to swap.

We are just starting, so the complexity of the problems may deviate somewhere from your or my expectations. Wait and see.

The first "thank you" is sent to antontrygubO_o, who helped with the review and selection of problems.

Many thanks to the testers: pashka, 300iq, vovuh, Golovanov399, spookywooky, kocko, Sho, igor_kz, Sho, scott_wu, bfs.07.

I hope you enjoy the problems, and the round will be interesting!

Please, leave in comments your thoughts about exactly this round. If you want to write something about the general idea of Div. 4, then visit this blog post.

UPD: Editorial is published!

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

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

finally ,, thank you :) ; i think this is my chance to become a specialist after 4 years in codeforces
really i solve 2 problem in Dev2 .. so i will try my best here

»
5 years ago, # |
  Vote: I like it -24 Vote: I do not like it

is it rated for unrated accounts?

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

All I want is a smooth and queue free contest today

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

How to become tester for CF round? Are testers author's friends or something else?

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

For testers this problems is easy. Maybe before the round gives this problems to grey people?

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

    I don't think so! Usually high-rated people tend to keep the problems secretly!

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

Hello!

If i have 1400+ and only 1 rated round and i'll write this div.4 will the rating be recalculated?

Thanks for the new contest :)

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

    I think it won't be rated for you.

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

    Sorry, no. Actually, I have plans to reduce the initial rating (from 1500 to 1200 or even 900). It will remove a series of rating drops in the first contests.

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

      This will be a lot better.

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

      Maybe to 1300 or 1400?

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

      Please be careful, new rating may become more expensive than the old one (new rating will be harder to get than it was earlier, so it will be impossible to compare old participants with new one).
      Also without additional measures you may get the same rating drop but starting from a new initial rating.
      Have you considered a few "qualification" rounds instead? Eg. first 2-4 rounds participants has only hidden rating and they get their rating and color only after qualification series finished. This system implemented in some games, eg. Starcraft.

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

      Mike now that new comers start with 1500.They lose points. Which is gained by experienced users. But if you start their ratings st 900. It will become more difficult for experts and specialists to gain rating changes.

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

GOOD LUCK TO EVERYBODY!

»
5 years ago, # |
Rev. 3   Vote: I like it -20 Vote: I do not like it

Affect of Div.4 contests on us:

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

I am looking forward to the problem A. How much difficult it is!

»
5 years ago, # |
  Vote: I like it -31 Vote: I do not like it

Will it be unrated? Like last round?

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

    Because I know you all have so many questions, I have compiled an FAQ:

    Q: Is it rated?

    A: Yes.

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

Hope Not to See Atcoder's ABC's A and B problem :)

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

Today ,we are going to witness a historical moment and be part of it .

Upcoming generation will witness this post and will be enlightened by our high intellectual comments and will praise our intelligence. (First div 4 round on CF)

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

What is the meaning of D3A-D3D problems?

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

By seeing the upvotes of this blog we can imagine how codeforces comunity got disappoint after div4 got introduced :(

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

    I am new to CodeForces and I am sorry for this question but why does div4 disappoints the community?

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

    Or maybe the majority of people upvoting are pupil and noobies (happy with the free rating increase for them) which constitutes 90% of the codeforces traffic.

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

There seems to be an unwritten rule to not post an editorial before end of hacking phase. I do not see the point. People discuss problems in the comments anyway after the coding phase.

Is there an official opinion?

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

    No such official rule. I think it is quite OK to post an editorial before the end of an open hacking phase.

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

Thank you MikeMirzayanov for running an awesome platform not only for advanced users! Maybe it will be helpful for newbies like us.. We will try to give our best shot :)

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

Is it rated?

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

this(division 4) will be helpfull. great idea..... :)

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

All time high.. 26K+ participants ..wow

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

Still long queue?

»
5 years ago, # |
  Vote: I like it -26 Vote: I do not like it

is this a really Div.4 are you sure???

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

Well, usually I hate problems with test cases, but not in this case.
Samples are so strong so I can just submit the solution without carefully checking the answer, since WA 1 doesn't count.
I really appreciate it. Thanks, Mike.

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

    I would recommend checking for the sample tests before submitting though. It's the least we should do to put less load on the server.

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

      Since Mike wanted to test the system under load, I think, it's even better to submit a solution whenever you think you're ready. (and, probably, resubmit after WA1)

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

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

Nice contest!! (Although there can be a slight increase in difficulty of F or G as also in Div3 end questions are around 1700-1800 rating.)

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

The queue time almost does not exist! Thanks for the great round!

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

    well there are 40+ pages on queue so...

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

      40 pages = 2-4 min of queue

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

      40+ pages of pretest. The setters are trying their best to put a lot of good test cases in a small amount of cases. I dont think it would be an issue.

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

What div.1 and div.4 have in common for me: having nothing to do for about half an hour before the end.

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

    ayaya that made me laugh but its mutual

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

      Thx! That's why I chose Codeforces. It's a good website to learn English and get contribution as well.

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

Very good work of the codeforces administrators, the queue time was significantly reduced. The queue time for round 639 was around 40 minutes while in this round the cap was 2 minutes. I think codeforces is ready for div 1 and div 2. Thank you for your wonderful work.

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

I solved all problems in this first contest of Div 4!!!

I'm so happy about it!!!

Officially, I have the 12 place in official list of participants!

Predictor says that I will have +330 rate!!!

Amazingg~!!!!!

Love you, Mike Mirzayanov!!!!!

P.S. Mike made my dreams come true!!! I really want T-shirt with your autograph, cause you are my superstar!!!

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

    Congratulations. Keep this motivation, and you will be successful.

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

    Well done! Now make sure you won't get hacked :(

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

    I doubt if you've done it yourself. I'll personally check all your submissions on my MOSS and report any plagiarism case to codeforces. Simply not possible for a grey (unless alt ofc)

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

      Bro chill. No need to report him to CIA.

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

      If I remember correctly, you are that guy who defended Karan Gujjar. Now u r accusing everyone of cheating. This contest was no big deal anyone could have solved all the problems. Instead of motivating him, you are accusing. Grow yourself

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

I think the order was a little unbalanced. It should be

A C B D E G F

OR

A C B D G E F

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

    OR A C B D G F E

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

      I dont think so F was the most difficult problem acc to me

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

    A C B D E G F seems to be the order of difficulty according to the AC counts.

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

    Really? I thought E was simple and didn't require any experience dealing with similar problems, even though you had to work around the memory limit some. Meanwhile I had no clue how to approach G since it wasn't something I was familiar with.

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

      Solution of E Odd numbers in decreasing order then 4 then even numbers in decreasing order. For n = 8 7 5 3 1 4 2 6 8

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

        Damn, knew it was some trivial pattern I was missing. Thanks!

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

          I also didn't find a pattern at first, so I did a dfs search to find the solution.

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

            Can you explain further how can dfs be used to find pattern ?

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

              You consider all the numbers as nodes. The edges are between the pair of numbers that are 2-4 away from each other. The you start dfs searches from all the n numbers and try to somehow get all of them in one search. You can check my code for details. The complexity is O(n^2) however.

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

        Isin't this the solution of G.

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

    If you are a Newbie,I think ACBDGEF is better

    (But it is ACM-ICPC so it doesn't matter)

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

Problem of long queue has improved a lot wrt last div1/2 contest!

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

When you solve 4 problems in div3, but here you solve one......

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

I like problem A. It is easy but interesting and has an educational value.

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

Unofficial editorial in Python 3. For more editorials see my discord http://interview.solutions

Problem A
Problem A - Tutorial
Problem A - Solution
Problem B
Problem B - Tutorial
Problem B - Solution
Problem C
Problem C - Tutorial
Problem C - Solution
Problem D
Problem D - Tutorial
Problem D - Solution
Problem E
Problem E - Tutorial
Problem E - Solution
Problem F
Problem F - Tutorial
Problem F - Solution
Problem G
Problem G - Tutorial
Problem G - Solution
  • »
    »
    5 years ago, # ^ |
    Rev. 3   Vote: I like it +11 Vote: I do not like it

    In E you could also check if any window on this array sums up to a[i]. Sliding window works for O(n), so the total time complexity would be O(n*n) and no additional memory needed, except for the array itself.

    P.S. Okay, I didn't see that you use only O(n) memory, so nevermind, your solution is better.

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

    Thank you so much,mogul!

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

    For G you can reduce by 4 and then handle 3 cases

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

      I think simplest solution is starting with length==4 and then add odd numbers to the left, and even to the right until the wanted size is reached.

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

    Thank you!

    Really concise and to-the-point editorial.

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

I loved Problem G! It reminded me of one of my favorite problems on Codeforces: 24 Game

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

Hi everyone! I uploaded screencast of this contest by this link (Solved all problems in 48 minutes!).

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

Hey which approach in problem E would cause MLE?

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

    I used a set to store all possible sums, which caused MLE.

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

      Ohh then I think space complexxity with O(n^2) will cause MLE

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

      My workaround was to only store possible sums $$$\leq max$$$ and that passed.

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

    This solution got MLE, submitted to PyPy 3

    for t in range(int(input())):
        n = int(input())
        a = list(map(int,input().split()))
        PST = [0 for i in range(n+1)]
        for i in range(1,n+1):
            PST[i] = PST[i-1]+a[i-1]
        special = {-1}
        for i in range(1,n+1):
            for j in range(i+1,n+1):
                special.add(PST[j]-PST[i-1])
        ans = 0
        for x in a:
            ans += 1 if x in special else 0
        print(ans)
    

    I switched to C++ so I could use a bitset<8000*8000> instead.

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

      for all i <= n we have a_i <= n so you don't need to save sums > n.

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

        You're right! That totally slipped my mind. I forgot that you only needed to check numbers within the array itself if they're special anyway. Good catch.

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

problem set was great. and I think your experiment has become successful. Today There is no Inqueue problem.

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

Since I was tester in this round I was not able to participate. But I used the time to write an unofficial editorial

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

The problems were easy but very interesting!

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

I think there are some problems with that. According to the prediction results of CF preidcitor, the div4 rank1 will increase 341 score after this round. So, his new rank will be 1733 (1392+341). I think it unbelievable. Maybe his new rank is too high.

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

    Yes. this is unbelievable. By participating div2 or div3 one can be hardly rated like this. so I think Mike should change his strategy.

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

    If we could solve all questions in 47 mins, he definitely deserves expert

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

      I'm just taking rank1 as an example. I mean maybe the strategy should be changed a little.

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

It seems that we can't view other's source after the contest?

UPD: it's ok now

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

I'm not sure if it's only me, but while submitting a solution I kept receiving a message saying "Unexpected error". This happened for about 5 minutes and then everything was normal again. What could be the reason?

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

I think it could've been div3 if one more difficult problem was added, and 1-2 current problems removed?

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

    I don't think so Problems were relatively easier than Div3 No Graph dp or greedy.. Div3 contains at least 2 problems including such topics and hard brainstorming :)

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

    According to me problems feel significantly easier than Div3, even F and G feel approximately the same level as an average Div3 D / Div2 C. Usually Div3 F is also fairly tricky and comparable to Div 2 D level problems.

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

how is it possible to have runtime error on c++ 11, but not on c++ 17, when someone uses only vector?

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

I was about 30 seconds short or else I would have officially done that last problem...
Anyways I enjoyed this round and it really for first time in life taught me that i should have good typing speed
I encourage to have more div.4 rounds
It motivated me a lot

»
5 years ago, # |
  Vote: I like it -9 Vote: I do not like it

Not satisfied with the order of problems!!!

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

    With me, the G problem is easier than the F and E, but I couldn't solve it in time:((

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

The first time I solved all of the problems. What an amazing first experence to me. I'm so happy to attend this round even though I'm out of competiton.

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

Thanks MikeMirzayanov for providing such contests. Finally I have solved a problem in an online contest. Thank you for providing such contest . Also, introducing Div4. contest was an awesome initiative. Keep continuing such kind of contests.

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

Why am I in practice mode, and how do I hack?

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

Good time , why my code for problem A with g++11 compiler got wrong but with g++17 got Accepted? from the begining I try to change my code and fix it , after the contest I got problem is the compiler I choose for code :(((

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

Simple solution for problem G: if n<4 clearly no answer exists else first keep 3,1,4,2 in a deque and alternate appending elements between left and right. My submission link

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

Simple solution for G again!

Put odd elements first in decreasing order then from even elements first put 4 then 2 then same order from 6 till last even element in increasing order.

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

Although it's div4, I still think it's very difficult. Maybe I'm too bad.

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

Did anyone else feel that the level of Div 4 was somewhat similar to Div 3? I mean, there is a noticeable difference between Div 2 and Div 3 but I don't think i can say the same about Div 3 and Div 4. (In the previous three Div 3 contests, I could comfortably solve 2 questions well within 30 mins but could only solve A and C today). Anyways, the problems were good, hope to see more such contests.

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

    Yes even I feel the same, Last time I was able to solve 3 div3 questions but today I got struct at problem 2nd

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

    That was because ABC of div4 had identical difficulty to ABC of div3. The difference was DEFG of div4 were same as D of div3

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

Why does not O(n^2) solution for E TLE? I thought they reduced constraints to keep those away, and tried to do that in LogN time. Still, 8000^2/2 is a lot of time for one second, and solution passes in 70 ms. What about cases with all 1's?

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

    $$$O(n^2)$$$ for $$$n=8000$$$ is $$$64000000$$$ which is less than $$$10^8$$$ operations. Codeforces can comfortably handle $$$10^9$$$ basic operations in one second, so a $$$O(n^2)$$$ algorithm is safe to use.

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

      10^9 operations take 2 seconds or more.

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

      n*n*logn is giving tle. I checked using map. So 10^9 not possible in 1s i think.

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

        use unordered_set instead of map which will give constant O(1) time on average for element access and insertion and also would use less memory than unordered_map

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

          I solved it using integer array instead of map. I was just checking whether n*n*logn passes or not.

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

            Heyy i just saw a something unusual
            When i generated a testcase of 8000 1's and fed to my program it tool ~3.5 seconds and on codeforces same solution and same testcase have time of 155ms for solution E
            UPD: Now i just ran my program with -O2 command for optimization. Sorry for such noobie question

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

              The 3.5 seconds benchmark is from your computer?

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

                Yehh i just don't know what happended
                But when i used -O2 in compilation command it reduced to ~0.29 seconds
                I am not able to find what cause such an optimization to my byte code

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

                  Then it's not comparable. You can use codeforces custom test to make valid comparison

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

                  Thanks buddy

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

          correct! map is a self balancing BST! so operations like searching are O(log n) and for inserting its O(log n + balancing time). unordered_map is a hash table so average search time is O(1) , worst time could be O(N) if collision occurs in hashing data.

          PS: if anyone could explain me about balancing time of BST.

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

            To explain balancing of BST a few tree is necessary to draw. The BST are generated in such a way that it has equal left and right child. So that searching complexity is always log(n). For this purpose tree may need to be rotated after insertion of value.

            You better search google for more explanation using graph. Red black tree is one of the self balancing BST.

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

              thanks! I have recently started with trees and graphs.I ll try to search it and learn more!

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

      yeah Correct, but it depends on heaviness of operation too, like modulus and division are costly for processor.So for safe limit I take 10^8.

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

I solved just one problem. It was still fun because I could finally read the problem statements and know what was expected of me. I hope to get better in the upcoming rounds

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

A very cool round. Keep the good work going, Codeforces administration team.

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

Nice problem set

»
5 years ago, # |
  Vote: I like it -15 Vote: I do not like it

Screencast of this round. Click here , I was able to solve upto F.

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

    Congratulations. I would have probably solved problem F had the contest duration been 2:15 hours instead of 2:00 hours.

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

I doubt,that one test included n=0

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

    I'm talking about last problem

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

      Why do you think so? Constraints says n>=2

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

        Because I tested it for all 2<=n<=1000,there was no problem. then I tested it on test n=0 which gave me runtime error. Verdict was also runtime error.

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

Nice problems! My screencast of the round in Chinese bilibili BV1tT4y137wS, don't forget to 一键三连!

Interestingly, the Div4 seems to be harder than the first few Div3 rounds (although Div3s are relatively harder now). Do you have the same feeling?

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

    i request you to screencast in english that will help lots of people who don't know chinese.

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

      You see, there are some other English screencasts, you can watch them. My English is not good enough to record a screencast fluently. And for the same reason as yours, I also want to help those Chinese that are not so good at English. Sorry~

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

Could someone try and hack my D? PS : I think the worst case is with 200 test cases each having 1000 elements. Also I didn't use 2 pointers, and it is most possibly O(n^2) per test case.

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

    Can you show a link to your solution, thanks

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

    I tried hacking it with 200 testcases and each testcase with 1000 elements such that each time only one element will be chosen by either of them. It worked fine or I wrote the generator wrong.

    Your solution in worst case loops (n*(n+1))/2 times. that is (1000*500) = 5e5 for each testcase which means 1e8 for 200 testcases and I guess 2 sec is enough for that.

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

    Looks like,worst case for your solution is T=200,where every case is - "1000 1 3 5 7 ..... 6 4 2". This is working in 421ms.

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

This round was super frustrating for me! I've been putting a ton of hrs to get better at CP (DP, Graphs, Fenwick tree, strings..). But then I face problems like B or C where I don't really know how to tackle those, and there are Math formulas that I'm simply missing. :( Any suggestions on how to improve for those kind of problems. Thank you.

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

    Do not try hard stuff. Just try to solve A and B more and more (to decrease the time) then gradually move to C, then only you have to learn some algorithms and data structures that you can easily find in tutorials also.

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

    I have never learned Fenwick tree. I think what you claim to know is more or less everything needed to get to Div1. Just try to solve problems from the actual rounds.

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

wow spookywooky becomes tester(cyan as well XDXD #worst year \ (•◡•) /)

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

Can somebody explain why this solution to problem E is getting TLED ?? 79579514 it runs I think within 1 sec locally.

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

    Use vector instead of maps, and do not mp = mp1; instead do mp.swap(mp1)

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

Hey guys, I'm curious about the solution of Question E.

You can actually exhaust all intervals in the array and compute all possible special numbers and got AC. How could O(N^2) solution with N<=8000 pass 1000ms?

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

    The O(n^2) solution is accepted. Because the server can do 10 million operations in a second

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

      Isn't the square root of 10 million around 3150? I actually gave up the O(N^2) solution and didn't submit anything for E because I thought it would have TLE, turn out it's acceptable...

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

        Just try it. There are only +/- operations so that the server can do more operations in a second.

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

    Because for n=8000, n*n=6.4*10^7 and 10^8 iteration can easily pass on 1000ms

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

      But, the overall time complexity is around T*N*N = 10^3 * 8*10^3 * 8*10^3 which is crossing even 10^10 shouldn't get TLE on that?

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

        It is guaranteed that the sum of the values of n for all test cases in the input does not exceed 8000.

        So t*n will be at most 8000 and t*n*n=8000*n which will never cross 6.4*10^7

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

    N^2 turns out to 64000000 < 10^8 which roughly takes 1000ms

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

div 4 was a great round

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

Here is a video solution to this contest: https://www.youtube.com/watch?v=w11pV4hPCxE

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

MikeMirzayanov, I want you to take action against them. Look at their submission for problem G. https://codeforces.me/contest/1352/submission/79508238 and https://codeforces.me/contest/1352/submission/79550067. Two submissions are almost identical. They also got hacked in problem A with almost identical code. They might share code as they are classmate!

»
5 years ago, # |
  Vote: I like it -27 Vote: I do not like it

Не могу сдать решение задачи F Восстановление 01-строки на Паскале (на пример посылка №79588069) . При проверке и запуске на сайте программа останавливается при вводе тройки данных "2 0 0". Переставлял эту тройку данных внутри теста — далее её не идёт вывод ответа. На своём компьютере получаю верный ответ 000.

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

It is really really helpful.. please increase the frequency of such contests bcz it boosts the confidence of new comers .

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

Finally a good contest... It will definitely boost our(newbie) confidence.
Hey, codeforces if you are listening we need more contest like this...

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

Have we got a conclusion that the server works ok and there will not be a long queue problem?

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

Reading through Mike's post and comments here I really appreciate all the efforts he is putting into trying to make codeforces more inclusive. Added to that how quickly codeforces acted on the changing of its growing community.

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

@MikeMirzayanov Hi Mike. Please see this when you have time. https://codeforces.me/blog/entry/59228#comment-428171

I knew it will happen like this. And I'm sure div 5 is comming.

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

I just want to say this.. Please include better sample cases for upto B problems if possible. (The sample test cases missed out on couple of crucial edge cases and had me running for it for an hour)

The problem D has good sample cases and I do not see why it would hurt to include a couple of testcases for the easier problems (logic wise)

Its hard to debug an easier problem with too many edge cases as intuitively it feels too correct.

(Just leaving my thoughts as implied in the blog)

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

is this contest not rated? Because it is written Contest finished but rating is not updated

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

    Updated now.

    Please be patient. System has to catch cheaters after the contest, which requires time.

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

I used ideone for my submissions. As I am new to competitive programing, I was unaware of the fact that ideone makes our code public.Apparenty someone stole my codes and used for submissions. Now I am receiving a message from codeforces that my account may be blocked. Please help.

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

    Do not use ideone again.You must keep your code private.

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

Maybe I find a bug in the rating calculating..?

yet_another_ATS was -18 before this round.

But in the contest rating change page,he is 100 → 994,+894.

And in his homepage,he is -18 → 994,+1012.

What's wrong? MikeMirzayanov

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

    It seems that for participants with rating lower than 100, during rating calculation they are considered 100.

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

MikeMirzayanov Only trusted participants of the fourth division will be included in the official standings table. This is a forced measure for combating with unsporting behavior. To qualify as a trusted participants of the fourth division, you must:

take part in at least two rated rounds (and solve at least one problem in each of them),

still many new account gain +300 rating is this is bug or contest is rated for new account.

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

    This contest is rated for new account.

    if your rating is less than 1400 (or you are a newcomer/unrated), then the round will be rated for you.

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

      then u don't think this is unfair for many expert and specialist... in this contest new account gain 100-300 rating.

      future : div4 ==> fake(new) account contest

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

        well,there may be some new pupils and newbies,so i think it's necessary for div.4 rounds to be rated for new accounts.

        anyway no one can stop the high-rated ones using new accounts xd

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

          well i think differently this contest is rating for div4 (<1400) it should be unrated for new account or new account rating should be dropped from 1500 to somewhere 1000-1300

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

            oh,this may be a good idea.

            after calculating the rating change,for unrated ones,their rating can't go up but only go down.if they go up,just ignore the change and let the account be 1500,specialist

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

    They will be not in official standing but rating will be changed for everyone who has rating less 1400 and who is unrated no matter he is trusted or not.

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

5000+fake accounts this time:(

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

The round was rated only for people having rating 1400 below ,,,, The max rating gain is +365 ,,, Which means the person's rating went above across 2 divisions!!! Is that a fair thing ? Im not sure though ,,, maybe it is ,, maybe it isnt !

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

Hey, pls check the rating changes, there is a bug. The participants whose rating was 1500 got an increase in the ratings.

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

    For those participants, this contest was their first codeforces contest. The initial rating of a new participant (unrated user) is 1500. That's why their rating has been changed.

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

Users who have created new account, and have got top ranks in this contest, have got a huge increment in their ratings. Their final rating is more than 1800. This is because their initial rating is already 1500. This is not fair, I guess. To handle this situation, the new participants in Div. 4 contests may have less initial rating (around 1400), rather than 1500.

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

    So far the only people I have seen complaining about this are cyans and low experts. Coincidence? I think not.

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

      First of all, I would like to add that even I could have created a new account and according to my ranking, I could have easily got a rating much higher than what I currently have. But it's unethical.

      Instead, It is just the true and fair spirit that we are trying to promote. Hope it clears the whole point.

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

Hi Mike! I have a question for you: will you do another div4 contest or this was the only one? Thanks! Luci

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

ok, bad idea(

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

Thanks mike! ,for this Div.4 round...I had lost my confidence somewhere but now after giving this round it has come back...I want to see more numbers of Div.3 or Div.4 rounds so that we can move one step forward in this journey of competitive pragramming. once again thanks mike and all other helpers to prepare this rounds....it was great idea.

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

Could someone explain in the example for problem E why the answer is 4 if n=8 and a=[8,7,6,5,4,3,2,1]? Isn't the answer supposed to be zero?

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

    It isn't because

    $$$a_2 = a_5 + a_6 = 4 + 3 = 7$$$
    $$$a_3 = a_6 + a_7 + a_8 = 3 + 2 + 1 = 6$$$
    $$$a_4 = a_6 + a_7 = 3 + 2 = 5$$$
    $$$a_6 = a_7 + a_8 = 2 + 1 = 3$$$
»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

What does D3A-D3D mean?

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

    This refers to a typical difficulty of problems in Div3 contest given as problems A to D. ie not very difficult problems.

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

will there be any more div 4 rounds?