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

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

Hi everyone!

It's been a while since I set problems for Codeforces competitions, so I hope that you had sufficient opportunity to rest before dealing with my problems again. Oh, no-no, there's nothing to worry about! Probably! I promise!

jeroenodb and adamant (that's me!) are happy to invite you to Codeforces Round 869 (Div. 1) and Codeforces Round 869 (Div. 2) which are going to take place at Apr/29/2023 17:35 (Moscow time). Participants with a rating strictly lower than 1900 will participate in Division 2, while participants with a rating of at least 1900 will participate in Division 1.

All the problems are prepared by us, and we would like to thank:

In both divisions, you will have 2 hours and 15 minutes to solve 6 problems.

Score distribution in both divisions: 500 — 1000 — 1250 — 2000 — 2500 — 3000.

Good luck and have fun!

The editorial is out.

Congratulations to the winners!

Div. 1:

  1. A_G
  2. tourist
  3. ecnerwala
  4. heuristica
  5. QAQAutoMaton

Div. 2:

  1. RGB_ICPC4
  2. elizazh
  3. lintd
  4. -LAP-
  5. STOC
  • Проголосовать: нравится
  • +318
  • Проголосовать: не нравится

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

As a tester, I enjoyed testing the round. Good luck to all the participants!

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

As a tester/problem discusser, I hope the participants like the problems as much as I did.

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

As a back-to-back tester, I really enjoyed testing this round! very interesting problems )

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

As a tester, I saw a twist on one of the problems that I have never seen before!

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

As a tester, Best contest I have ever seen!

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

writing announcement 4 days before the round -> good round

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

As a tester, I regret not doing this round officially.

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

неееееееееет

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

As an early tester, I'm pretty sure I haven't seen the newer problems but I'm sure they'll be interesting.

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

As a tester the round has cute problems :DD

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

As a participant I won't participate

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

As a participant, I will try my best to participate in the contest. I hope I will give my best.

And also best of luck everyone.

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

Holy hell, so many testers!

Hope this round is cool

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

Is it rated for everyone?

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

As a Div 3 tester, this round will be interesting and challenging for Div 3 participants. Good luck and hope you enjoy the round! :)

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

As a first-time Div.1 participant, I hope that I stay at Div.1.

UPD: Mission accomplished somehow.

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

Very early score distributions indeed!! ♥

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

Clashes with LeetCode Biweekly 103

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

:)

Div.1 and Div.2 will both be rated?

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

Good Luck for all participants

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

How many common problems between the divisions? Can't figure out from scores.

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

Hopefully to reach cyan again!good luck everyone!

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

Hey if anyone is interested in becoming friendly competitors, you can reply I'll add you and we can compete together during contests.

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

How to Approach hard problems D, E and F in DIV2

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

Hoping to solve till Div 1 C today and achieve my first ever rating plus as master, and first ever rank maintainance as a separate Div 1 participant.

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

Good luck to all the participants ;)

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

It is game time.

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

people who will realize div2 c twist after contest :( me who got it during contest :) after getting two WA

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

you are too day^-1

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

Many people would have left due to problem A. 17k registrations and only 6k participants

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

explain C, pls

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

I'm not a good fisherman bcz I couldn't catch the fish from the graph(problem D xD)...

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

The webpage with a simulator for problem D was very helpful. Thanks!

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

No tougher A please, people are simply skipping contest after seeing A.

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

Can Someone Tell The Idea For Problem C If Instead of Subsequences It Was Subsegment?

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

    Use prefix sum. For each query, do casework on l

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

    I misread the problem during contest and wasted my time solving "Subsegment" version ;(

    I don't know if it have simpler solution but I have a possible solution for "Subsegment" version of Div2C using segment tree in $$$O(n + qlog(n))$$$.

    Here is my code

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

      i was also solving for subsegments initially the problem then essentially reduced to taking max of intersection (l,r) over certain intervals which i was not able to figure out within the time constraints

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

The demo page really helps a lot when solving div1 D.

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

Hi, the system verdict my solution was used the edge (2,4) twice while I checked the output, it doesn't seem like that. I don't know what's happen. Is my solution wrong or is there any problem with the verdict system? https://codeforces.me/contest/1818/submission/203958546

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

Excellent fishy contest

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

Is it me or C was disgusting to implement?

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

For Div2, difficult A and nice C.

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

anyone pls explain how to approach b in div2

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

    Write brute force for $$$n\leq{10}$$$ and try to see a pattern... unfortunately that was enough to solve a problem.

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

    If n is odd the there will not be an answer because sum of array = $$$\frac{n(n+1)}{2}$$$ will be divisible by n.

    So, now assume n is even. Now consider the permutation p = [1,2,3,4,5,6,7,8,9,10,....] and array a = [2,1,4,3,6,5,8,7,10,9].

    If len = r-l+1 is odd. then p[1...len] would have been divisible by len. Also the p modulo len : p[i]%len would be repeating. For example, modulo 3. p = [0,1,2,0,1,2...]. So any subarray of len would be divisible. By making it into array a, we would make sure that in any subarray of len, there is exactly one different element in a than perm.

    If len is even. Again p modulo len would be repeating. And for any subarray of len in perm. sum modulo len is $$$\frac{len}{2}$$$. In array a, if subarray starts at odd index(1-based) then set of elements modulo len would be same as in p. But if subarray starts at even index, say l and ends at r(r = l+len-1), the a[l] = perm[l]-1 and a[r] = perm[l]+1. So total sum still remains $$$\frac{len}{2}$$$ modulo len

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

IN DIV2 D,

We just check for all vertices who have atleast 4 neighbours, whether they are a part of a cycle or not.. Am i missing something?(except implementation)

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

How to solve Div2E/Div1C? UPD: Nevermind, gonna read the editorial

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

Div1C may not be suitable here. I think Div1C should focus on thinking, and only use basic algorithms like dp or greedy. But this problem is nearly a pure math problem.

Anyway the problem is very nice. Using it in icpc contests may be better.

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

    Isn't Div1C focused on thinking and doesn't use any algorithms at all?

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

      after getting the answer in terms of the coefficients, i think its mostly more knowledge based, both the approaches to compute it (seems to me) you need to know it, or you cant do it.

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

        Well, yeah, you might be right. But I feel like it's a pretty basic math fact. And even though I knew it, when I acquired a formula via coefficients it took me a long time to realize that I could use interpolation to get one coefficient because it was a new angle for me on this. I think I have never before used the interpolating polynomial in competitive programming.

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

          I had never heard of lagrange interpolation before :(, and i consider myself more versed in maths than an average person since i did make our countrys tst.

          Ofcourse, its my skill issue, and i learnt something new now, but i think maybe you are biased about it being a basic math fact(for its level). I know a lot of my friends who were in the same boat as me, having got the answer in terms of the coefficients, but no clue on how to proceed.

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

div1 D was just playing the demo game :sob:

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

In $$$B$$$ I wrote something weird and it passed. Is it correct?

Iterate over all edges. Fix edge. Let it be in the tail of fish, and let one of its vertices be the center of the fish. Do simple dfs, which will not go into fixed vertice in tail. When in dfs we try to go to center of fish, and there is at least one unused neughbour vertice of center, we found answer. Otherwise continue.

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

including yourself (member 1) this line should be bold on A (:

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

This was my first contest! Glad I passed at least pretests on A and B. Then I think I understood how to deal with div2C but my solution was too slow so I don't submitted. I preprocessed the whole array finding the bad triplets for which x >= y >= z. Then basically for each query I would count how many "bad triplets" fall totally into the interval [l, r]. Then I would subtract this number from r — l + 1 which would be the answer if no bad triplets fall inside. Is this approach reasonable? How can this be optimized?

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

dang I spent too much time thinking how to write d1B knowing the solution

My ideas on d1C

if we knew n-th and n-1-th coefficents of A and B then we know the answer to the problem, and to compute them (lets say we are finding for A) we use interpolation by Newton to gradually build A so that it satisfies first i+1 points and deg(A) <=i; if we modify for point i+1, then lets say P(x) was our previous polynomial, and now P1(x) will be modified P(x) P1(x) = P(x) + (x-0)(x-1)..(x-i)*((y[i+1]-P(i+1))/(i+1)!), and we just need to find P(i+1) to know the largest coefficent of P1(x), and the second largest coefficent of P1(x) will be largest of P(x) + ((y[i+1]-P(i+1))/(i+1)!)*(0+1+..+i), so we can always find two largest coefficents of P1(x) if we can quickly find P(i+1), but P(i+1) can be counted using interpolation by Lagrange, and since x[i]=i it looks like every L[i] is a factorial divided by two factorials and i(maybe (-1) in a certain degree), and if we could somehow update them fastly after each step, we could find P(i+1).

Is my approach correct, and if yes, then how do we finish this?

upd.: i checked the submissions and it loosk like there's something simpler, but I don't know

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

D1A/D2C: Let [L, R] be a maximal non-increasing block (which means a[i]>=a[i+1] for L<=i<R, L==1 or a[L-1]<a[L], R==n or a[R]<a[R+1]) is min(2, R-L+1). Therefore we can solve the problem by prefix sum, but we need to process for blocks on the boundary of the queried range.

D1B/D2D: We need to find a node u with deg[u]>=4 and a cycle contains u. We can build a spanning tree rooted at u of the component of u, and find an edge connecting nodes in different subtrees of u.

D1C/D2E: If d==1 the problem is simple: Since A(x)=a1*x+a0, a1=A(1)-A(0), and B(x)=A(x+s)=a1*(x+s)+a0=A(x)+a1*s, so s=(B(0)-A(0))/a1. If d>1 we can find the (d-1)-th order difference of A and B, they will be polynomials of degree 1, and solve the problem as d==1.

(d-1)-th order difference
»
4 года назад, скрыть # |
 
Проголосовать: нравится +15 Проголосовать: не нравится

It seems that conqueror_of_tourist beats tourist again.

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

Fuck me xd I haven't cleared that shit after debugging:

Nice contest, had fun

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

    Huh, no random maxtest in E pretests?

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

      Generally, I didn't want to make pretests for this problem particularly strong, as the key observation could be guessed, and I didn't want people to brute-force their guesses against the pretests. Test 6 is quite large, but it only has very large numbers in the input. In the hindsight, I think I overdid it a bit, and it would be better to include the test 7 into pretests as well, and it was fully random.

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

        Did you explain your intention of the weak pretest to the testers or coordinators? If I were among them I would have strongly opposed the idea.

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

          I did not.

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

            That's pretty sad, but it doesn't surprise me. There were 33 testers and they didn't pay attention to this, while this is one of the things that they should exactly look for.

            I generally consider the quality of testing on codeforces as rather poor. Maybe it's a good idea to create some kind of checklist for them to follow, which would contain stuff like check the statement for unclear things and typos, check the strength of pretests (or at least if they contain a random maxtest/everything that they should contain), think if some problems have already appeared before etc?

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

              I think this in particular is because testers are simply not exposed to pretests/systests composition. Few years ago, testing was done on Polygon directly, and now it's just virtual contests in mashups, so they don't really get enough information for quality assurance.

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

          I want to say three things (I was the coordinator):

          1. I should have noticed the small number of pretests compared to the total number of tests (I usually suggest to the authors to have tests=pretests in hard problems, as antontrygubO_o suggested me when he coordinated me).

          2. My opinion is that weak pretests are always bad. I cannot think of a single exception.

          3. If adamant had told me that he wanted to have weak pretests because [see what he wrote above], I would have tried to change his mind. If he remained adamant (pun intended) about his decision, I might have allowed it. I feel like it is something an author can decide in certain problems (after all, Codeforces has never said explicitly anywhere that pretests are always as strong as possible), and this one is a problem where it makes sense (i.e., 1 person out of 10 might agree with Adamant).

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

            Thank you for explaining the situation.

            I too believe pretests should be as strong as possible. However, I know some people have a different opinion and they have a right to challenge the tradition.

            What I want to say is that they can try to change something, but it must be done through communication. This time it was done by a single person and I feel that is much more problematic than the weak pretest itself.

            If I had been consulted about this problem, I would have suggested adding the line "the pretest of this problem is intentionally made weak". This is just an example, but anyway hearing others' ideas could certainly make the situation better.

            I hope the future CF rounds will be prepared with better communication.

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

So happy to have AC-ed Div2C at 2:14:50 in the contest.

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

adamant Could you please mention first solvers for each problem ? Today is the first time for me to first solve problem. (Problem Div.2 B)

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

Rating boost thanks to div1C.

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

Very good contest. Div2C and Div2D were interesting.

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

As a tester, I hope that you have enjoyed this round.

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

Div1D is one of my favorite problems that I have seen on Codeforces, thank you.

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

Why are 6 files considered enough for Div1E's pretest... And if you know the solution you find the cases with small $$$n$$$ are not useful, and there exists only one (possibly) useful pretest. Why?

My bug is my fault (detail: I had to check cutting the leftmost/rightmost contiguous intervals (instead of just one element), but I am strongly against having deliberately weak pretests because the contest would heavily depend on hidden information.

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

    But it does depend on hidden information every contest, as long as it's not an official policy to make pretests sufficiently strong. At the moment, there is just no guarantee that the pretests are comprehensive, and you can't (and, imo, shouldn't) depend on it. Of course, one can argue that there should be such a guarantee, but (again, imo) to give it there should be a global decision, rather than just a tendency.

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

      Thanks for reply, yes, it does depend on hidden information every contest and that's why I dislike the current pretest rule. And your point:

      Of course, one can argue that there should be such a guarantee, but (again, imo) to give it there should be a global decision, rather than just a tendency.

      makes sense.

      Yet, in a particular contest, the more you put useless cases into pretests, the larger the factor of guessing hidden information, and the worse (I think) the contest becomes. Or at least "tendency" changes too much. I don't think it is good that one problemsetter can change it (In my opinion this is what the coordinators should keep).

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

Nice contest! Enjoyed D. B Failed system test, but appreciated to contest authors.

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

A_G hitting LGM in style 😎

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

div2 a > div2 b

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

This round was cool but i really hope we dont see more problems about polynomials at D2E/D1C, lol

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

Finally, my color got changed.

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

Problem A was a bit tricky tho(or the problem statement was somewhat confusing), it took me around 20 minutes to figure out the exact solution.

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

Div2 top5 are alt accs. As always :(

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

I know it's a different blog but why the upcoming contest 870(div2) registration will start at the time of starting of that contest then how people are supposed to register ?? or is it a bug?

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

ahrorov.5758

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

Can someone tell me how to solve Div1B/Div2D in $$$O(n+m)$$$?