TheScrasse's blog

By TheScrasse, 8 months ago, In English

Ciao, Codeforces! We're glad to invite you to take part in Codeforces Round 1053 (Div. 1) and Codeforces Round 1053 (Div. 2), which will start on Sep/24/2025 14:35 (Moscow time). You will be given 7 problems and 3 hours to solve them in both divisions.

Note the unusual starting time.

  • One of the problems will be divided into two subtasks.
  • One of the problems will be interactive, so please read the guide for interactive problems if you are not familiar with it.

The problems were authored and prepared by Dominater069, satyam343 and me.

We would like to thank

Score distribution:

  • Div. 1: $$$500 + 1000 + 1750 + 2500 + (2000 + 1750) + 3250 + 4250$$$
  • Div. 2: $$$500 + 1250 + 1250 + 1750 + 2500 + 3250 + (2750 + 2500)$$$

We hope you'll like the problemset!

UPD: Congratulations to top $$$5$$$ in Div. 1 and Div. 2.

Winners

UPD 2: the editorial is out.

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

»
8 months ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

almost all the authors & testers are RED

»
8 months ago, hide # |
 
Vote: I like it +48 Vote: I do not like it

As a tester, I highly recommend the interesting problems in the round!

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

Will be fun fs

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

testers OR!Z

»
8 months ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

Cant wait for another satyam round orz

»
8 months ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

Contest of my favourite coders!

»
8 months ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

Where is __baozii__? Does he want to reach IGM?

»
8 months ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

Satyam343 round omg

»
8 months ago, hide # |
Rev. 2  
Vote: I like it -48 Vote: I do not like it

Satisfactory contest time for Chinese participants huge W

As a participant, hope the contest has great problems and may it be cheater free!

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Satyam343's round omg!! Already scared.

»
8 months ago, hide # |
 
Vote: I like it -67 Vote: I do not like it

If your rating_range<=1600 then the 3 hour contests is not for you , it's for those cheaters.

»
8 months ago, hide # |
 
Vote: I like it +36 Vote: I do not like it

Please note the unusual start time

»
8 months ago, hide # |
 
Vote: I like it +64 Vote: I do not like it

As not a tester, I highly recommend the interesting problems in the round!

»
8 months ago, hide # |
Rev. 2  
Vote: I like it +16 Vote: I do not like it

So what is a ":smiling_face_with_sunglasses: :skull: :grinning_face_with_sweat: :upsidedown_face: coordination"?

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Where __baozii__ went?

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

my first div1

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Math contest is about to happen

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

500 to 1250.... damn. and C is also 1250

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Why the unusual timing on a weekday?

»
8 months ago, hide # |
 
Vote: I like it +4 Vote: I do not like it
»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

That's a hell of a coordination.

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

Here , Everyone is my favourite coder, especially Dominater069.

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Looking Forward to it!

»
8 months ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

Hope to reach CM :)

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Participating in this contest. My target for this contest to solve three problems. Best of luck to all participants.

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hope I can get a good grade

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How high the average rating of testers are...

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

excited

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Quite sad because I’ll probably miss this contest since it’s happening earlier than usual.

»
8 months ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

The time is really really wonderful!Finally no more staying up late!I would also like to thank the experts who set the questions and conducted the tests; your hard work is appreciated.

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

As not a participant, I will not participate

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I love java! console.log("hello world");

»
8 months ago, hide # |
 
Vote: I like it +40 Vote: I do not like it

Codechef admin coordinated a round on Wed. and clash with the Codechef round by 5 minutes :(

»
8 months ago, hide # |
 
Vote: I like it +46 Vote: I do not like it

»
8 months ago, hide # |
 
Vote: I like it +13 Vote: I do not like it

As a tester of the round based on OII 2025, I must show you this meme.

»
8 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Sad that I got classes on that time but best of luck to all other participants

»
8 months ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

Highly praise the friendly starting time!

»
8 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

The time is very kinds for Chinese OIer.I can play the contest but don't have to Staying up late.

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Is Div1 rated for everyone or just above master

Like can I register to Div1 today and be rated?

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Add time

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

zur

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Div.2 => Div.(1.5)Forces

»
8 months ago, hide # |
 
Vote: I like it -23 Vote: I do not like it

why my friend's account creative2024 be banned during the contest. He wonders how can he appeal under this situation.

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Jaw dropping Contest!!!

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

The queue is now over 10 minutes long, what happened?

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Why in queue?

»
8 months ago, hide # |
 
Vote: I like it +13 Vote: I do not like it

It’s been a long time since a Div. 2 B problem made me think this much.O⁠_⁠o

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

I hope everyone is enjoying.

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

Any intuition to Div2E?

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Was D that easy? How so many people solved it? How to solve it?

  • »
    »
    8 months ago, hide # ^ |
     
    Vote: I like it +9 Vote: I do not like it

    example image helped a lot in guiding my thoughts in correct direction.

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

    i think i got the pattern but wasnt able to implement it properly ... although i need to prove that that pattern is universal and then implement :((

  • »
    »
    8 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    You can prove (by induction on the rows) that the black squares aren't under the left and right diagonals. After that, iterate from the center of the square row $$$i$$$ by row $$$i$$$ and pick which $$$a_i$$$ black squares you want to keep in row $$$i$$$ out of the $$$n - \sum_{j \gt i} a_j$$$ you have remaining.

    You also need to check that $$$a_i$$$ add up to $$$n$$$ and that none of the ones after the middle are nonzero. All of this is relatively straightforward to prove.

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

disaster! can someone please give hints for Div 2 B (the contest is over)?

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

    you can do greedy solution.. the main thing that you have to observe is that looking for next white cells by brute force does not actually give TLE.. cause at some point next cell will be out of range of the existing set. at least i passed the pretest with it.. don't know what will happen in system testing

  • »
    »
    8 months ago, hide # ^ |
    Rev. 3  
    Vote: I like it 0 Vote: I do not like it

    It can be done greedily in one pass. The only time a next person is gonna be at different cell than where current person ended while following command 'B'. Since ending at command 'B' makes the cell black, and for the next person, he must be at next white cell when following the B command

    for (int j = 0; j < n; ++j) {
        if (c[j] == 'A') {
          p++;
        } else {
          p = findNextWhite(p + 1, black, nextWhiteMap);
        }
        black.insert(p);
    
        if (c[j] == 'B') p =findNextWhite(p+1, black, nextWhiteMap);
      }
    
»
8 months ago, hide # |
 
Vote: I like it +6 Vote: I do not like it

Sooooooo Hard B and C TAT. I'm not good at them,but I learned a lot.Thanks for the contest

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

The problems were exciting. Nearly solved 3 this time, couldn't figure out how to optimze O(n²) to O(n)

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

problems B and C are consisted of pretty simple ideas, but finding out it took to many time for me...

»
8 months ago, hide # |
 
Vote: I like it +25 Vote: I do not like it

Why were the hacks disabled for Div2B $$$?$$$

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

Spent a lot of time thinking on E, but couldn't formulate anything. Can someone explain?

  • »
    »
    8 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it +8 Vote: I do not like it
    Hint for D2E
»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Honestly I have no idea how my E12 passes, how to calculate random shuffles fail probability?

  • »
    »
    8 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    How shuffling work? So if a problem is hack-free then likely it is probability-based? Only saw one other problem like this before. And isn’t the proper way of solving recursively dividing the array into 2 and ask to see the single value appear in which part? Although that gives the wrong guess for version 2.

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

      Usually when the problem has fixed number of tests, you might consider writing some randomized algorithm. Probably there are another cases where problem needs fixed number of tests while not using randomized algorithms, I don't know them tho.

      You can use shuffled indexes for queries while dividing the array into 2. This should reduce number of queries, but i am not sure how much it reduces.

      Also your code finds correct guess for version 2, but just uses too many queries i guess

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

        Thanks! I will have to see the editorial. The reason for the wrong guess was because wrong implementation during optimization. Overall it was still too many queries.

»
8 months ago, hide # |
 
Vote: I like it +31 Vote: I do not like it

Div1 E1 is kind of problem that makes people submit the worst ideas they've got. My local stress started passing on 3:14 and it was not enough to fix minor stuff and submit :cry:. Not sure what was the purpose and intended approach of the problem, need editorial.

Div1 BC are sweet, F is interesting (like I dont even understand how one can solve bamboo in 2 rounds). I definitely had some troubles with the way some problems were formulated — maybe this is even good against LLM's understanding problems but unfortunately it's also against me understanding problems.

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

hints for C? didnt have to time to find C since spent so much time for B

  • »
    »
    8 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    You want to delay people from leaving for as long as you can; how can you do this?

    Spoiler 1
    Spoiler 2
    Spoiler 3
    • »
      »
      »
      8 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      I got the observation in first go but somehow couldn't code it. Can u give me some hints on how to go about implementing it?

      • »
        »
        »
        »
        8 months ago, hide # ^ |
        Rev. 2  
        Vote: I like it 0 Vote: I do not like it

        You need to be able to:

        1. sum up a prefix in $$$a$$$
        2. sum up a suffix in $$$a$$$
        3. sum up some subarray of alternating positive and negative elements of $$$a$$$

        You can easily do 1 and 2 with a regular prefix sum. For 3, you'll need to calculate two prefix sums (or notice that $$$\text{psum}_1 = -\text{psum}_2$$$ and just negate), one for $$$[a[0], -a[1], a[2], -a[3], ...]$$$ and one for $$$[-a[0], a[1], -a[2], a[3], ...]$$$. Once you have these, you can just use them to calculate the middle part.

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

        Compute an array of segments seg[i] = a[i+1] — a[i], then build two prefix sum arrays: pre_odd for odd-indexed segments and pre_even for even-indexed segments. For k=1, take the sum of all odd segments. For k>1, exclude the first and last k-1 segments of the relevant parity (odd if k is odd, even if k is even) and use the prefix sums to quickly calculate the sum of the middle segments. Keep counters of how many odd/even contributions have been used so far, and iterate this process for all k.

      • »
        »
        »
        »
        8 months ago, hide # ^ |
        Rev. 2  
        Vote: I like it 0 Vote: I do not like it

        for n=6, the signs will go like this. find a way to add this pattern

        k=1 [ -ve +ve -ve +ve -ve +ve ]

        k=2 [ -ve -ve +ve -ve +ve +ve ]

        k=3 [ -ve -ve -ve +ve +ve +ve ]

      • »
        »
        »
        »
        8 months ago, hide # ^ |
        Rev. 2  
        Vote: I like it 0 Vote: I do not like it

        Thank you everyone (◕‿◕✿)

        UPD: I finally got AC. My submission

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

      my proof for c: any two consecutive segments would differ by 1 in contribution, as the point between them would be used as entrance or exit to already entered visitor. to prove why the said construction works, we can see that parity of contribution of an segment remains same so 4 contribution segment couldn't do 5 contribution(). now we greedily chose maintaining contribution<=k.

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

today, maybe I'm spcialist

»
8 months ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

div2 a is fun, but what's the meaning of div2 b and c, and c is so typical!

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I have a max flow solution for Div2E is it supposed to pass

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

It was intresting lol

»
8 months ago, hide # |
 
Vote: I like it -18 Vote: I do not like it

I worked out CTS2024D1T3 so I know the solution of 1F but I forgot there is T in 1E so I have no time to finish 1F

»
8 months ago, hide # |
 
Vote: I like it +12 Vote: I do not like it

This was my hardest contest so far, maybe I’m too used to quick A/B solves :)

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Why Foredawn is not banned even he is unrated and solved 7 problems

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

Hey is it rated

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Anyone give me some hint how to approach the problem B div2 i was unable to do that...

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

    so you can simulate the whole process in O(n*n) .. but the observation which I made was if you process i+1 character, only thing which matter is what you did with i-th character ... so you don't need to start from the beginning again ..

    try to work with this hint ...

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

      bro i also in confuse that how do i know the next Black cell

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

        so store all black cells in a set ( in cpp ) and if you just increment the position and check if that position is black .. this will not time out.. because in one operation you can only make once cell black. so you will not check more than 2*10^5 cells in worst case.

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

      That's neat, how did you come up with this intuition?

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

        I think it is just practice but also constraints tell me that it can't be O(N*N) so I tried to think of something faster.

        but the fact that you only paint 'ONE' cell in your last step helps .... because when you start next time all that portion before the cell colored last time will be same.

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

Any editorial for E div2?

  • »
    »
    8 months ago, hide # ^ |
    Rev. 3  
    Vote: I like it +11 Vote: I do not like it

    Define $$$p_a(i)$$$ and $$$p_b(i)$$$ to be the positions of element $$$i$$$ in the preference arrays of Alice and Bob respectively.

    Let's say that the set of elements Alice takes is $$$i_1, i_2, \dots i_m$$$ where $$$p_a(i_j) \lt p_a(i_{j +1})$$$ ($$$j \lt m$$$).

    How exactly can we get Alice to take exactly this set of elements?

    • Bob takes elements until all elements in the subarray $$$a[1, p_a(i_1))$$$ have been taken.
    • Alice then takes $$$a[p_a(i_1)]$$$
    • Bob takes elements until all elements in the subarray $$$a[p_a(i_1) + 1, p_a(i_2))$$$ have been taken.
    • Alice takes $$$a[p_a(i_2)]$$$. .
      .
      .
    • Alice takes $$$a[p_a(i_m)]$$$.

    Notice that when taking $$$a[p_a(i_j)]$$$, it must obviously not already have been taken by Bob.

    We therefore derive a necessary and sufficient condition for a subset of elements $$$S =[i_1, i_2, \dots i_m]$$$ to be attainable by Alice:

    $$$\max_{k \leq p_a(i_j), k \notin S}(p_b(a[k])) \leq p_b(i_j) \forall (i_j \in S)$$$

    This motivates the following naive dp formulation:

    Define $$$\text{dp}(i, x)$$$ to be the maximum score of some Alice-attainable set $$$S$$$ from the prefix $$$a[1, i]$$$ wherein $$$\max_{k \leq i, k \notin S}(p_b(a[k])) = x$$$. The transitions take the following outline:

    dp[0][0] = 0
    for i from 1 to n:
        #we take the current element
        for x from 0 to p_b(a[i]) - 1:
            dp[i][x] = dp[i - 1][x] + v[a[i]]
        #we dont take the current element
        for x from 0 to p_b(a[i]) - 1:
            dp[i][p_b(a[i])] = max(dp[i][p_b(a[i])], dp[i - 1][x])
    

    This runs in $$$O(n^2$$$) and it's trivial to optimize the transitions to $$$O(n \log(n))$$$ using segment trees.

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

    There is a n^2 dp solution where dp[i][j] — maximum value of first i items Alice has taken when Bob has taken j of his first items.

    Let p[i] — position of element i in Bobs list

    The transitions from i to i+1 when someone takes item a[i].

    For each j:

    • if Bob has already taken this item dp[i+1][j] = dp[i][j]

    • if Bob hasn't taken this item dp[i+1][j] = dp[i][j] + v[a[i]] (Alice takes the item)

    • Bob can take the item if not taken yet dp[i+1][p[a]] = $$$\max_{0 \leq k \leq p[a[i]]}$$$ dp[i][k]

    This solution is n^2 but it can be optimized by saving this dp in a lazy segment tree.

    This is my solution, don't know if intended

»
8 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

It was a horror show...!

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Amazing problems , enjoyed Div 2 B...

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

I got a solution of D1E with expected $$$3.5n+2\log_2 n$$$ on average, and failed both E1 and E2.

Then I improved the solution to $$$2.75n+2\log_2 n$$$, passing E1 and E2 at the same time, despite that $$$35$$$ of $$$10^6$$$ local tests failed. (which seems to be too bad, as E1 has around $$$3.2\times10^5$$$ testcases.)

No idea of why did it get accepted, and why are the boundaries $$$4n+2\lceil \log n \rceil$$$ and $$$925$$$.

  • »
    »
    8 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    Your solution seems actually slightly better than what you stated (see the editorial). It's intended for E2 but not for E1. Maybe it passes on E1 as well because TLE submissions on Codeforces are rejudged.

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

    For E1, your asymptotics don't matter on small tests. If you're not guaranteed to fit in the small query limit for small $$$n$$$, you're out of luck.

  • »
    »
    8 months ago, hide # ^ |
     
    Vote: I like it +26 Vote: I do not like it

    Well, it turns out that I was too sleepy last night and I made a typo in the local tests. I set the bound to $$$4n+\lceil\log n\rceil$$$ instead and that caused a slight chance of failure. Now it failed $$$1$$$ case among $$$10^7$$$.

    My bad, thanks anyways.

  • »
    »
    8 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    same problem

»
8 months ago, hide # |
 
Vote: I like it +21 Vote: I do not like it

The round I reach GM.

»
8 months ago, hide # |
Rev. 2  
Vote: I like it +74 Vote: I do not like it

Lost the opportunity to jump over IM in somewhat amusing way...

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

What do you guys think of problem B and C's rating?

I learnt that I need to practice more greedy/implementation/construction problems in a similar range :(

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

it was hard for me because i'm newbie

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Appeal for Flag on My Submission 340186188 for Problem 2151E

Hello Codeforces team, I would like to appeal the flag on my submission 340186188 for problem 2151E in this contest.

I would like to assure you that I wrote my code independently and did not share it with anyone or view anyone else's solution during the contest. The similarity in the solutions is only coincidence due to the nature of the problem itself.

My Logic for Problem E I solved using a dynamic programming approach, but to make it more efficient I also optimised my data structure. As you may know, this is a standard technique in competition programming. The logical steps to think of this solution are quite constrained, which could lead to similar code from my peers. Here are my steps: 1. My primary thought is to process Alice's preferred items one by one. It is natural to maintain dp[j] to represent the maximum value of Alice's items after Bob has picked his j most preferred items.

  1. A naive O(n^2) dp solution would be too slow. As I notice that we must update range and point between states, I decide that a Segment Tree is the fastest data structure to optimise the program to O(nlogn). My code uses a segment tree and lazy propegation to handle the range additions faster.

  2. When I am processing Alice's i-th preference A[i], I let its position in Bob's list be p. The logic inside the loop is divided into cases:

    • Case 1: Alice takes A[i]. This is possible if Bob did not take it yet. In this case, Alice's value increases by v[A[i]]. This is implemented as a range add operation st.add(1, p, v[A[i]]).
    • Case 2: Alice does not take A[i]. This means Bob will eventually take it instead, which is B[p]. To handle this transition, I need to find the best possible score Alice could have gotten before this turn by using st.queryMax(1, p). This value is used to update the state when Bob takes p items, which is what st.chmaxPoint(p+1, bestPref) line does in my program.
  3. My segment tree code is a standard template I used for many problems. Data structures have common structure, using function names like build, push, add, and query. Variables like mx for maximum and lz for lazy are also common. Maybe this is one more reason why my solution looks similar to my peers.

In conclusion, as this specific dynamic programming method is the most efficient way I could think to solve the problem, it is maybe also that other contestants who are familiar with these methods would think of the same logic and similar implementation.

Proof of Innocence

I wrote my code within my local Visual Studio Code environment and did not use any public IDEs like ideone.com. I am not sure how to find the cache/logs or file histories, but if you would inform me on what details you would like to verify, I can try providing. To avoid this in the future, I will use a local Git repository.

Thank you for your time. I am just a mathematics and computer science university student trying out the Codeforces platform. I have read the rules and understand them very seriously. I hope this explanation clarifies my solution and shows that it is my own independent work.

Sincerely, ComplexBulb

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Appeal for Plagiarism Flag on My Submission 340173657 for Problem 2151D

Hello codeforces team, I am writing again to appeal second flag I received from same contest. This appeal is for my submission 340173657 for problem 2151D. Once again, I want to say that my submission is my own work. I did not teamwork with anyone, nor did I find external solutions during the contest. The similarity I guess comes from the mathematical and algorithmic type of the problem.

Explanation of My Logic

This problem is a combinatorics and counting problem.

  1. The problem's constraints on black cells can be reduced to a known problem of counting permutations with restricted positions (such as placing n rooks on an nxn board without attacking each other). My solution uses a formula derived from this.

  2. The number of valid grids can be calculated with the following steps, which my code implements directly:

    • A necessary condition for this problem is that the total number of black cells must be exactly n. If not, the answer is 0. My code first checks this.
    • then, the idea of my solution is using that the problem constraints can be modeled by a sequence m, such that m_k = min(k, n + 1 — k). This sequence will give me the available choices at each step.
    • The number of ways to place n cells according to the rules is given by Π (m'_i — (i-1)) for 1 ≤ i ≤ n, and m' is sorted(m). My code calculates this product. The line pref[mi] — (i — 1) in my loop does this calculation, using prefix sums of a to find the available choices in the rows.
    • Last step is, since the a_r cells inside a given row r are indistinguishable, we must divide by a_r! for each row. I wrote my code by multiplying by the (precomputed) modular inverse of each factorial.
    • The functions for modpow and the precomputation of factorial and modular inverse factorials are fundamental tools for any combinatorics problem on the Codeforces competitions. This code is very common and similar across all programmers templates.
    • The rest of my main function is a direct implementation of my mathematical formula. I simply calculate m, sort m, calculate prefix sum, apply the product formula. This is the most simple and logical way to implement the solution. There is very less creative difference in this type of solution.

As the solution is a direct implementation of a mathematical formula, most people who correctly solves the problem will produce code that is similar with me in logic.

Same as my previous appeal, I wrote this code in my Visual Studio Code local development environment. I am fully prepared to explain my thought process and the derivation of the formula in more detail to prove that my understanding is my own.

Sincerely, ComplexBulb