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

Автор MikeMirzayanov, история, 4 года назад, По-английски

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!

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

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

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

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

is it rated for unrated accounts?

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

All I want is a smooth and queue free contest today

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

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

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

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

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

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

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

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 :)

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

    I think it won't be rated for you.

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

    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.

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

      This will be a lot better.

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

      Maybe to 1300 or 1400?

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

      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.

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

      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.

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

GOOD LUCK TO EVERYBODY!

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

Affect of Div.4 contests on us:

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

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

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

Will it be unrated? Like last round?

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

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

    Q: Is it rated?

    A: Yes.

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

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

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

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)

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

What is the meaning of D3A-D3D problems?

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

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

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

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

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

    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.

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

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?

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

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

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

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 :)

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

Is it rated?

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

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

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

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

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

Still long queue?

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

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

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

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.

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

    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.

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

      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)

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

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

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.)

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

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

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

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

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

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.

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

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!!!

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

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

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

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

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

    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)

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

      Bro chill. No need to report him to CIA.

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

      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

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

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

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

    OR A C B D G F E

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

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

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

    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.

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

      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

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

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

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

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

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

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

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

              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.

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

        Isin't this the solution of G.

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

    If you are a Newbie,I think ACBDGEF is better

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

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

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

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

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

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

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

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

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
  • »
    »
    4 года назад, # ^ |
    Rev. 3   Проголосовать: нравится +11 Проголосовать: не нравится

    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.

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

    Thank you so much,mogul!

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

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

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

      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.

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

    Thank you!

    Really concise and to-the-point editorial.

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

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

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

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

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

Hey which approach in problem E would cause MLE?

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

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

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

    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.

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

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

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

        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.

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

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

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

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

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

The problems were easy but very interesting!

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

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.

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

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

UPD: it's ok now

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

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?

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

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

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

    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 :)

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

    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.

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

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

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

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

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

Not satisfied with the order of problems!!!

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

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

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

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.

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

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.

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

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

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

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 :(((

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

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

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

Мне кажется, меня обмануло "С целью отсечения эффективных решений от неэффективных в этой задаче ограничение времени довольно строгое. Постарайтесь написать в самом деле эффективное решение." в Е — особые элементы.

Я полчаса думал и пытался придумать что-то эффективное. Не придумал. Написал самое простое решение на C++, работающее за O(n^2) и использующее O(1) дополнительной памяти — просто для каждого из чисел в массиве проверяю, может оно быть составлено или нет. И получил полное решение.

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

    держу в курсе, что квадрат и есть оптимальное решение

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

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.

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

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

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

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.

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

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

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

    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

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

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?

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

    $$$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.

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

      10^9 operations take 2 seconds or more.

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

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

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

        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

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

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

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

            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

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

              The 3.5 seconds benchmark is from your computer?

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

                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

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

          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.

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

            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.

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

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

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

      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.

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

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

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

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

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

Nice problem set

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

Поделюсь здесь решением задачи G.

Заметим, что решений для n <= 3 не существует, потому в таком случае выводим "-1". Иначе давайте ответ будем хранить в двухсторонней очереди (в с++ для этого можно использовать deque<>). В самом начале давайте будем сзади добавлять все нечетные числа в промежутке [1..n]. Затем давайте добавим в начало "4" (поскольку мы рассматриваем решения для n > 3, всё законно) и "2". Затем будем в начало добавлять все четные числа в промежутке [6..n].

Конечным ответом является получившаяся очередь.

В справедливости решения убедиться довольно легко — разница между любыми соседними чётными или соседними нечётными числами в точности равна двум, разница между "1" и "4" равна 3, между "2" и "4" равна 2 и, наконец, между "2" и "6" равна 4.

#include <bits/stdc++.h>

using namespace std;

void Solve(){
    int n;
    cin >> n;

    if(n <= 3){
        cout << -1 << endl;
        return;
    }

    deque<int> deq;
    for(int i = 1; i <= n; i += 2) deq.push_back(i);
    deq.push_front(4);
    deq.push_front(2);
    for(int i = 6; i <= n; i += 2) deq.push_front(i);
    for(int i : deq) cout << i << ' ';
    cout << endl;
}
 
signed main(){
    int test = 1;
    cin >> test;
    for(int i = 1; i <= test; i++)
        Solve();
}
»
4 года назад, # |
  Проголосовать: нравится -15 Проголосовать: не нравится

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

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

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

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

I doubt,that one test included n=0

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

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?

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

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

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

      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~

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

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.

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

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.

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

    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.

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

    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.

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

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

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

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

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

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?

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

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

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

      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...

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

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

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

      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?

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

        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

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

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

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

div 4 was a great round

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

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

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

MikeMirzayanov, I want you to take action against them. Look at their submission for problem G. https://codeforces.com/contest/1352/submission/79508238 and https://codeforces.com/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!

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

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

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

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

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

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

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

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

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

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.

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

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

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

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

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)

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

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

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

    Updated now.

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

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

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.

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

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

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

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

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

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.

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

    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.

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

      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

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

        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

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

          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

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

            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

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

    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.

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

5000+fake accounts this time:(

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

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 !

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

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

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

    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.

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

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.

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

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

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

      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.

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

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

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

ok, bad idea(

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

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.

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

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?

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

    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$$$
»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

What does D3A-D3D mean?

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

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

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

will there be any more div 4 rounds?