sunbrey's blog

By sunbrey, 4 days ago, In English

Hello, Codeforces :3

I am thrilled to invite you to Codeforces Round 1138 (Div. 3), which will start at Nov/27/2026 17:35 (Moscow time).

Then round will last 2 hours and 15 minutes and you will be given 7-8 problems to solve. The round will be rated for participants with a rating lower than 1600.

Remember that only the trusted participants of the third division will be included in the official standings table. As it is written by link, this is a compulsory measure for combating unsporting behavior. To qualify as a trusted participant of the third division, you must:

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

Regardless of whether you are a trusted participant of the third division or not, if your rating is less than 1600, then the round will be rated for you.

I put a lot of effort into preparing this round, and I hope you’ll enjoy reading the problem statements as much as I enjoyed writing them. Each problem picks up where the previous one left off. I hope you’ll make it to the last problem and read the story all the way to the end.

I would like to thank Vladosiya for the helpful feedback and assistance with preparing the problems. Special thanks to:

  1. MikeMirzayanov for Polygon and Codeforces platforms.

  2. Friendiks, KotlechkovEgor, semwin2008 for helping me improve the problems.

  3. MikeMirzayanov, zhichenlin, Timosh, wery0, JedbyKey999, itz_pabloo, vanta5n, grigalex40, xinerx for colorful and wonderful testing.

The round will be hosted by rules of educational rounds (extended ICPC). Thus, solutions will be judged on preliminary tests during the round, and after the round, it will be a 12-hour phase of open hacks. After open hacks all accepted solutions will be rejudged on successful hacks.

Good luck and have fun!

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

»
3 days ago, hide # |
 
Vote: I like it -24 Vote: I do not like it

6 testers working overtime so I can get WA on test 2 in problem A. Respect!

»
3 days ago, hide # |
 
Vote: I like it +49 Vote: I do not like it

wow we had MikeMirzayanov as an author and now as a tester!

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

Waiting for Mike to comment "As a tester..."

»
3 days ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Love when problems share a connected storyline! Looking forward to the round, thanks for preparing it :3

»
3 days ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

Sir Mike as a tester hits crazy, now Sir Mike only wasn't translator if I'm right?

how you think guys?

»
3 days ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

cute plushies

»
3 days ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

i hope i cross 1300 in this contest

»
3 days ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

Black testing orz

»
3 days ago, hide # |
 
Vote: I like it +6 Vote: I do not like it

is that omori & aubrey on the picture? how cute

»
3 days ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Omori round <3

»
3 days ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Good luke,guys!/Удачи, друзья!

»
3 days ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Who're the two cute characters in this picture?

»
3 days ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Hello!

This is gonna be my first round actually, and I am pretty excited!

I wonder what rank would I get... :)

»
2 days ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

no game theory problem please

»
2 days ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hi lol

»
2 days ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

i came, i saw, i solved, i solved, i kept solving, i got -ve, i slept.

»
2 days ago, hide # |
 
Vote: I like it +12 Vote: I do not like it

I shed a tear...

»
2 days ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Isn't that Omori and Aubrey ? Kinda cute to see em here

»
2 days ago, hide # |
← Rev. 2  
Vote: I like it -7 Vote: I do not like it

.

»
41 hour(s) ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

So excited to read the story!

»
41 hour(s) ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Thanks for the contest!!

»
40 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

good luck everyone

»
40 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Drop a like for a cookie, please

»
31 hour(s) ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

omori round we sleeping good tonight

»
30 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Its my first, it starts in 10 mins. I am scared!

»
28 hours ago, hide # |
← Rev. 2  
Vote: I like it +2 Vote: I do not like it

My account ilia_rr just got disabled mid contest. Is there an official procedure for appealing the suspension or contacting the administration to have my account reviewed?

  • »
    »
    28 hours ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    I'm in the same boat, my account Catman6094 got disabled. I really want to at least know why this happened.

    • »
      »
      »
      27 hours ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      It says "Unexpected Precipitation, Skipped" as verdict. It probably is the automatic cheat detection system, so there should be a way to request a review.

»
28 hours ago, hide # |
← Rev. 2  
Vote: I like it +1 Vote: I do not like it

Is this a real div3 contest?

»
28 hours ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

holy difficulty

»
28 hours ago, hide # |
← Rev. 8  
Vote: I like it +5 Vote: I do not like it

Nice contest, here are solution sketches for A-G:

A. Simulation, $$$O(l+a+b)$$$

B. Sort the array, and for every block of $$$k$$$ consecutive elements either eat them individually or make juice, whichever is optimal, $$$O(n \log n)$$$ due to sorting

C. The answer is YES if and only if $$$n$$$ is even and the string is not alternating, $$$O(n)$$$

D. Right to left DP, store the best possible score for each player (max for Sunny, min for Aubrey) if they are currently on the left, transitions are $$$dps_n = \max(x_n-y_n, 0)$$$, $$$dpa_n = \max(y_n - x_n, 0)$$$, $$$dps_i = \max(x_i - y_i + dps_{i+1}, dpa_{i+1})$$$, $$$dpa_i = \max(y_i - x_i + dpa_{i+1}, dps_{i+1})$$$, answer is based on $$$dps_1$$$, $$$O(n)$$$

E. Binary search on the answer, for $$$m$$$ steps the smallest possible position of Aubrey where $$$y = \lfloor m/(k+1) \rfloor$$$ and $$$z = m - y(k+1)$$$ is $$$(2^y-1)(k+1-z) + (2^{y+1}-1)(z)$$$, $$$O(\log^2 k)$$$

F. Create an auxilliary directed graph of $$$2n$$$ nodes where $$$n$$$ are a "black mode" and $$$n$$$ are a "pink mode" which represent the next edge color you must traverse to keep the path alternating, and check if there is a cycle in it, $$$O(n+m)$$$

G. Sort the array, the optimal set of pictures to choose for a tournament is the first $$$n/2$$$ and last $$$n/2$$$, the optimal order eliminates the largest elements last, brute force on every tournament size, $$$O(m \log m)$$$

Trivial bonus for G: Solve it with update queries

Spoiler
  • »
    »
    28 hours ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Could you explain the math in $$$E$$$ in more detail? How did you derive the solution from the start?

  • »
    »
    28 hours ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    bruh i was hesitant to dp for D cuz div3 D. Thank you for the sols <3

  • »
    »
    28 hours ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    How do you arrive at that conclusion for problem C? How can we find that invariant?

    • »
      »
      »
      28 hours ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      The even length is pretty simple as you delete 2 bits every time

      For the alternating string condition we can see that the operation keeps the string alternating and neither 01 or 10 work

      You can keep any other string non-alternating and therefore it will eventually end up as 00 or 11

      • »
        »
        »
        »
        27 hours ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        that was your thought during the contest ? you had to guess that

        • »
          »
          »
          »
          »
          27 hours ago, hide # ^ |
          ← Rev. 2  
          Vote: I like it 0 Vote: I do not like it

          I noticed that alternating strings didn't seem to work and I tried them and saw that it was because they stayed alternating, then tried a few other cases knowing this condition to see if everything else worked. And the even one isn't very hard. It was definetly quite guessy though.

        • »
          »
          »
          »
          »
          27 hours ago, hide # ^ |
           
          Vote: I like it 0 Vote: I do not like it

          Try to perform it on an alternating string, the operation does not change it, rest all strings can be emptied. Try it on a no. of different string combinations, you'll see that. So, I don't think it was guessing, just observation.

        • »
          »
          »
          »
          »
          26 hours ago, hide # ^ |
          ← Rev. 2  
          Vote: I like it +9 Vote: I do not like it

          If the initial string isn't alternating, then it's always possible to keep the string non-alternating after an operation, provided that $$$n$$$ is even.

          For simplicity, let's say the string has the longest contiguous span of 0s. Let $$$l$$$ be the length of the span ($$$l \ge 2$$$).

          • If $$$l \ge 4$$$, you can simply remove one 00.
          • If $$$l=3$$$, the string should contain 1000 or 0001 (because $$$n$$$ is even). Here you can apply the operation on 000 and you'll have 11 as the result.
          • If $$$l=2$$$, there are three possible cases.
            • If the entire string is 00, just remove them, and you are done.
            • If the string contains 0010 or 0100, then apply the operation on 010 and you have 00.
            • Otherwise, the string should contain 0011, 1001 or 1100. Just remove 00 and move on.
        • »
          »
          »
          »
          »
          25 hours ago, hide # ^ |
           
          Vote: I like it 0 Vote: I do not like it

          I did write all 16 strings with lenght equal to 4 and then guessed it. Then I just needed a prove (or just some half prove) which wasn't that hard to find.

  • »
    »
    23 hours ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Could you explain bonus G in depth

    • »
      »
      »
      22 hours ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it
      Spoiler
»
28 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it
  • »
    »
    28 hours ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    It isn't a greedy, it's a dp.

    • »
      »
      »
      28 hours ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      I think my solutions is already using dp (state transition) without naming the variables dp ^^

      Anyway, do you have a counter example?

  • »
    »
    28 hours ago, hide # ^ |
    ← Rev. 2  
    Vote: I like it +10 Vote: I do not like it

    Greedy Approach will not work in this case. Try to map the problem to the House Robber problem.

    And the reason why Greedy algorithm fails here is because skip doesn't mean a +0 but toggling the authority to someone else for later spendings.

  • »
    »
    28 hours ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    L: 1 100

    R: 5 5

    S will avoid but if it takes to the final result will be better than avoiding

  • »
    »
    16 hours ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Choosing a bigger number at an instant seems correct but think in terms of future , there maybe some choice that may not yield good at current moment but can be fruitful later , so greedy fails here we'll apply DP its because we have only two choices either skip or buy , and if we know the result for upcoming suffix( the subproblem we want to know answer of) then player can easily make a choice at index i to be at the left or swap positions , Consider reading minimax DP for more info .

»
28 hours ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

Guessforces

»
28 hours ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

C was a nightmare to guess

  • »
    »
    27 hours ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    I think I arrived at a complete proof.

    Odd lengthed or alternating strings are bad, so we talk about even lengthed and non alternating ones.

    Suppose we pick the pair (i, j) and call P = s[0 ... i — 1], X = s[i + 1 ... j — 1] and S = s[j + 1 ... n — 1]

    Claim: We can force PXS to be non alternating (empty strings are assumed to be alternating)

    Assume, that s[i] = s[j] = '0'

    The only way PXS can be alternating iff P, X and S are alternating and X connects to P and S with the same bit before flipping.

    First, assume that at least one of P and S is non empty. Assume that it is P and S is empty for convenience.

    The only problematic triplets are 101 and 000. However, 101 is not possible under our assumption because s itself would be alternating in this case.

    In 000, simply pick any but the middle 0 and the resulting string contains at least one equal and adjacent pair.

    If both P and S are empty and n >= 4, we can select a suitable same bit from X to reduce it to the previous cases.

    If X is empty, then there must exist only one pair of 0s and that too adjacent ie only one occurrence of "00". Even in this case, we can reduce the string to an empty one.

    So, I think the conditions are sufficient. I would be happy to have someone hack this.

»
28 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

OH GOD THIS ROUND TOUCHED ME INAPPROPRIATELY

»
28 hours ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

What are these names man

»
28 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Great contest, unfortunately I ran out of time before I could finish implementing F. Finally Specialist :D

»
28 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I don't know how to use dp to solve D...

»
28 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Does no greedy approach work for Problem D?

»
28 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Really enjoyed the questions in this round, sadly didn't do as well as I was hoping to but really liked the story part of these questions ❤️.

»
28 hours ago, hide # |
← Rev. 2  
Vote: I like it 0 Vote: I do not like it

4k people solve d! i think my rating is going to drop a lot

»
28 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Solved E but not D ToT

  • »
    »
    27 hours ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    how bro , D was easier then C and i couldn't solve E

    • »
      »
      »
      27 hours ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Not good at DP :( For E, the answer is monotonous and an upper limit is given, so use binary search. For each round you're checking, apply the compliments evenly so that Aubrey climbs the slowliest because she climbs faster and faster without the compliments. https://codeforces.me/contest/2292/submission/400052197

      • »
        »
        »
        »
        16 hours ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        1) I got the point the runs of Aubrey should be almost equal length

        2) Let's say we fix the no.of rounds R, then q = R/k+1 and rem = R%(k+1), then (k+1-rem) runs are of length q and rem rounds are of size q+1

        3) In this approach we can only check whether Aubrey crosses sunny after the last run, how to prove that it does not cross at any run in the middle

        • »
          »
          »
          »
          »
          14 hours ago, hide # ^ |
           
          Vote: I like it 0 Vote: I do not like it

          These contents are translated by GPT.

          We need to prove that checking only the final positions is sufficient, even though Sunny must stay strictly ahead after every round.

          Let $$$q=\lfloor m/(k+1)\rfloor$$$ and $$$r=m\bmod(k+1)$$$. The optimal strategy divides the $$$m$$$ rounds into $$$k+1$$$ blocks: $$$r$$$ blocks of length $$$q+1$$$, and the remaining blocks of length $$$q$$$. A block of length $$$d$$$ makes Aubrey climb $$$2^d-1$$$ steps.

          Define the net contribution of a block as

          $$$ F(d)=xd-(2^d-1). $$$

          We can arrange the blocks in non-increasing order of $$$F(d)$$$. Then, the differences between Sunny's and Aubrey's positions at consecutive block boundaries have non-increasing first differences. Thus, these differences form a discrete concave sequence.

          The same argument applies inside each block: after $$$s$$$ rounds, the position difference changes by $$$x-2^{s-1}$$$, which is also non-increasing. Hence, the position difference is discretely concave within every block as well.

          A discrete concave sequence attains its minimum at one of its endpoints. Therefore, if the initial and final position differences are both positive, the difference must remain positive at every intermediate round.

          Consequently, the condition

          $$$ \boxed{a+mx \gt H_m} $$$

          is not only necessary but also sufficient for surviving $$$m$$$ rounds. This justifies the binary search.

          • »
            »
            »
            »
            »
            »
            13 hours ago, hide # ^ |
             
            Vote: I like it 0 Vote: I do not like it

            "block boundaries have non-increasing first differences" this part gave me clarity, thanks :)

»
28 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Personally, I really liked the stories involving questions that were interconnected!

»
27 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

E looks like >:D

»
27 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

E seemed to be some reverse engineered maths formula

»
27 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hello sunbrey Vladosiya MikeMirzayanov

My account lydxn got disabled during the contest. I'd be grateful if an admin could check my account and a reason for the ban. As far as I'm aware I haven't broken any rules with regards to cheating or AI.

Thanks

»
27 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

peakmori round :O managed to solve A-G but not F it was lwk hard >w<

  • »
    »
    27 hours ago, hide # ^ |
     
    Vote: I like it +4 Vote: I do not like it

    Actually there is a simple solve for F: We can decompose the given graph as follows: a vertex $$$2u$$$ in the new graph will represent vertex $$$u$$$ from the original graph if we reached it via a black edge, while a vertex $$$2u + 1$$$ will represent vertex $$$u$$$ if we reached it via a pink edge. Once the edges in new graph are added correctly, we simply need to check for the presence of a cycle within each component of the decomposed graph (i used translator so sorry if smth is not understandable)

    • »
      »
      »
      26 hours ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      holy hell thats a nice solution brilliant of you to have seen that thank you

  • »
    »
    27 hours ago, hide # ^ |
     
    Vote: I like it +10 Vote: I do not like it

    Same qwq

»
27 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

such a boring two weeks with no normal contests :(

»
26 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

how to access editorial or blog regarding this contest??

»
26 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

D cooked mee

»
26 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

ughh 8 mins short for H

  • »
    »
    26 hours ago, hide # ^ |
    ← Rev. 2  
    Vote: I like it +10 Vote: I do not like it

    Congrats on 97th* (standings were weird, mb) as a newbie, curious how you did F? I had an idea, but I feel I overcomplicated it too much and was wondering if someone so strong as yourself could explain.

    • »
      »
      »
      25 hours ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Create two copies of every vertex — one for pink (u) and one for black (u+N), where N is the number of vertices.

      Edge Construction

      For each edge:

      • Pink edge → add (u, v+N) and (v, u+N)
      • Black edge → add (u+N, v) and (v+N, u)

      Each edge forces the "opposite side" vertex onto the other copy, which keeps the two colors consistent.

      Cycle Check

      Build the graph, then run topological sort. If the sort fails → there's a cycle → invalid.

      Component Count

      Count the number of distinct roots in the DSU. Each different root = one separate component.

      400045603

      • »
        »
        »
        »
        25 hours ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        LOL you made it worse bro

      • »
        »
        »
        »
        25 hours ago, hide # ^ |
         
        Vote: I like it +1 Vote: I do not like it

        BTW I asked how YOU did F. Not how AI did it for you :)

        • »
          »
          »
          »
          »
          25 hours ago, hide # ^ |
          ← Rev. 3  
          Vote: I like it 0 Vote: I do not like it

          nope, that's my own code — didn't come from AI

          only comments. :(

          • »
            »
            »
            »
            »
            »
            25 hours ago, hide # ^ |
             
            Vote: I like it 0 Vote: I do not like it

            Imagine cheating and still losing to hit fraud sc3developer

            My idea for F was mostly the same as the slop above except you don't need toposort to detect cycles I just copied from geeks for geeks

            • »
              »
              »
              »
              »
              »
              »
              25 hours ago, hide # ^ |
               
              Vote: I like it 0 Vote: I do not like it

              i hate dfs

            • »
              »
              »
              »
              »
              »
              »
              25 hours ago, hide # ^ |
               
              Vote: I like it 0 Vote: I do not like it

              Explain more concretely, step by step, plz. I can not understand at all.

            • »
              »
              »
              »
              »
              »
              »
              25 hours ago, hide # ^ |
               
              Vote: I like it 0 Vote: I do not like it

              I got it solved (shoutout to qqrnt for helping me!) with similar DSU idea but I used SCC instead of topological sort

              • »
                »
                »
                »
                »
                »
                »
                »
                24 hours ago, hide # ^ |
                ← Rev. 2  
                Vote: I like it 0 Vote: I do not like it

                Only finding a cycle, you used SCC? Isn't it too expensive?

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  24 hours ago, hide # ^ |
                   
                  Vote: I like it +4 Vote: I do not like it

                  No? Both are $$$O(V + E)$$$. (Unless you were talking about expensive not in terms of runtime?)

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  23 hours ago, hide # ^ |
                   
                  Vote: I like it +1 Vote: I do not like it

                  SCC is only a bit heavier and gives a bit extra constant factor. though they're the same asymptotic complexity of $$$O(V+E)$$$. i think using SCC is still an overkill though since topo sort is simple. (。・ω・。)

»
24 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

way to bring back omori trauma :')

»
21 hour(s) ago, hide # |
← Rev. 2  
Vote: I like it 0 Vote: I do not like it

Hey Guys, sunbrey, MikeMirzayanov

thehvd3.redemption(click here) this is my account, while I was giving contest today, it was suddenly disabled. I request the moderators to please enable my account, as I was not doing any kind of cheating nor was I using AI. Also, what was the reasoning for disabling my account? Was it just the fact that a newbie account solved 4 que in 30 min?

  • »
    »
    19 hours ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Because you are more clever than AI. Those who clever than AI often got this kind of terrible stuck.

  • »
    »
    19 hours ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    I can't see your submissions for some reason, but I could imagine having 2 accounts doesn't exactly increase your chances of an appeal.

»
21 hour(s) ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

why are so many succesful hacks getting TLE verdict on problem D?

  • »
    »
    16 hours ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    maybe some ppl may have used recursion + memo (using map ) ??

  • »
    »
    15 hours ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    I saw many people had the same solution with different variable names, stuff moved around and different templates: bottom-up 2D DP that checks if a state has been computed by asking if dp[x][y] != -1. Then a hack forces as many as possible valid states to be -1 so that at every step of recursion it has to reconstruct the whole memo table, thus O(n²) time.

»
15 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I have a question, how to have a CP online community where everyone discuss about CP and improve together

»
15 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hello, I submitted a solution for problem D during Codeforces Round 1138, but it does not appear in my submissions or the standings. My handle is bhaumik2427, and I submitted at approximately 10:20 pm in India using C++. Could you please check whether the submission was received?

»
11 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I really like problem H although I can not solve it in Contest ^^, but now I can solve it. The idea burned my head ^^

»
11 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I participated in the live contest, but my profile still shows no rating change.That's why??

»
10 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

New color :yayy:

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

wow, i dont expect, what this tasks will be about Omori game :)

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

can someone explain H?

  • »
    »
    37 minutes ago, hide # ^ |
    ← Rev. 3  
    Vote: I like it 0 Vote: I do not like it

    Consider the information of each node independently, let it be $$$u$$$ and suppose it is the root. Call an $$$i$$$ good if it's the first time $$$e_i$$$ transfers information from the parent to the child, the amount of people knowing the info of "$$$u$$$" is the amount of good $$$i$$$.

    Note that this sum only changes if we remove one of the good $$$i$$$, and the next time the same edge $$$e_i$$$ appears again let it be $$$j$$$.

    So the difference after removing $$$i$$$ is just the amount of good $$$k$$$ in the subtree of $$$e_i$$$ originally minus those $$$k$$$ coming from the new $$$j$$$.this gives the idea of dp, let $$$dp_i =$$$ the amount of good $$$k$$$ in the subtree of the edge of $$$i$$$ if $$$i$$$ were to be a good index.

    we can compute it from right to left and $$$dp_i =$$$ sum of the dp for each node that is direct child of the "child" of $$$e_i$$$.the the answer is $$$dp_i - dp_{i'}$$$ for each good $$$i$$$. Where $$$i'$$$ is the next appearence of $$$e_i$$$this runs in $$$O(NM)$$$

    the idea to optimize is noting that each edge has two different orientations. for example imagine an edge like this :

    U
    |
    V
    

    when we take anyone above $$$u$$$ or $$$u$$$ as root the subtree of $$$v$$$ is always the same so we can build another dp considering these orientation where $$$dp_{i, \text{flag}} =$$$ is basically the same thing of the aforementioned dp but $$$\text{flag}$$$ is $$$0$$$ or $$$1$$$ defining whose from $$$u$$$ and $$$v$$$ is the "parent"

    so now we could theoretically go for each $$$i$$$ and calculating how many nodes $$$x$$$ above $$$u$$$ have $$$i$$$ as a good edge.

    to discover this we can just consider the same dp but in reverse since note that a information going from $$$u$$$ to some $$$z$$$ is the same as rooting in $$$z$$$ and it goind to $$$u$$$ in reverse.

    So it is just how many nodes $$$z$$$ before $$$i$$$ have edge $$$i$$$ as good minus how many $$$z$$$ before $$$i"$$$ have edge $$$i$$$ as being good (where $$$i"$$$ is the previous appearence of $$$e_i$$$).

    using some precalculations for nodes we can bring the complexity to $$$O(M + N)$$$

    Code

    I hope it is clear, feel free to ask questions.

»
6 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hello, sunbrey and MikeMirzayanov.

I created this account solely to post an appeal on behalf of my original account, maltta900, which was disabled during this round. After reading the comments, I noticed that several other participants experienced the same issue. I would greatly appreciate it if you could manually review my case and clarify the reason why my account was disabled. And I emphasize that I've strictly followed the rules for the contest. I am willing to cooperate with the review process, provide any relevant information, and explain my submissions. I respect the Codeforces community and its rules, and I sincerely hope my case can be reconsidered. Thank you for your time and consideration.

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

Can anyone pleasee explain how to solve problem H

»
3 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I made a short comment on this yesterday, but I decided to ramble a bit more here. I'm assuming from previous comments that I should ping these people to get their attention. Feel free to let me know if I'm wrong: MikeMirzayanov sunbrey Vladosiya

I decided to join these contests a couple weeks ago, and this is my second one. I really enjoyed trying to do these problems quickly, but my account Catman6094 was "disabled by administrators" mid-contest. I got no message of any kind explaining what triggered this, and I did not cheat in any way that I know of (I didn't collaborate, plagiarize, or use AI tools in any way). Cheating is completely pointless and takes away from the joy of actually solving a problem for yourself. Cheaters clearly don't understand this joy of problem solving. Anyways I've created this new account to try and get the disabled one reenabled.

For reference, here are my solve times, which you can check on my disabled profile:

  • Problem A: 5 minutes after the beginning of the contest
  • Problem B: 11 minutes after problem A (after a wrong answer because I forgot to use 64-bit integers lol)
  • Problem C: 8 minutes after problem B
  • Problem D 12 minutes after problem C

I was solving E when the account was disabled.

Do these solve times seem fast for a new user? I don't know for sure because I'm new to the community, but if so, it should be noted that I have prior experience from the Project Euler community. I got hooked on Project Euler a few years ago, and I've solved 360 problems there over the course of a few years. This experience is how I've been improving my coding skills, and it carried over to Codeforces. I don't like defending myself like this because it feels too much like bragging, but I don't know what else to say.

So I am requesting that either my account Catman6094 is reenabled or at least please give me a legit reason for the ban. It is very frustrating to be banned without being given any explanation, because I don't know how I'm supposed to defend myself. I understand the paranoia around cheaters these days, what with AI growing in power, but I hope somebody considers looking into this.

Regardless, I have really enjoyed solving problems here for the past few weeks! In this contest, I found the pattern in problem C very satisfying to spot. I love inductive patterns like this one :) I also really enjoyed problem E, but sadly didn't get to submit it during the contest. I will keep solving problems here, but I guess I'll just avoid the contests if this isn't resolved.

Thank you and have a good day!

»
2 hours ago, hide # |
← Rev. 2  
Vote: I like it 0 Vote: I do not like it

MikeMirzayanov sunbrey

Hello Mike, sorry to bother you here. My old Codeforces account kishan108 was suddenly disabled without any warning or explanation. I cannot log in, and my profile shows "The user is disabled."

I have already contacted the administration and sent you messages, but it has been over 7 weeks without a response.

Could you please review my account and explain the reason for the restriction? If it was a mistake, I kindly request your help in restoring it.

»
84 minutes ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

The Editorial is taking FOREVER to come out. Can someone PLEASE explain how to solve E? I have some intuition from reading other's submissions but I am not able to prove it.

»
24 minutes ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

It was like i didnt even solved a single problem then after the contest i thought the first question is maybe gcd and its was actually gcd ... ...