Bufu's blog

By Bufu, 2 months ago, In English

Hello, Codeforces!

We are excited to invite you to participate in Codeforces Round 1115 (Div. 2), which will take place on Aug/06/2026 17:35 (Moscow time).

The round will be rated for all participants with a rating below 2100. Participants from Division 1 are warmly welcome to participate unofficially.

You will be given 6 problems and 2 hours to solve them.

The round was prepared by TomitaMatei and me, Bufu.

We would like to express our deepest gratitude to everyone who made this round possible:

  • cry for their excellent coordination and infinite patience while reviewing the problems!
  • Alexdat2000 for translating the statements to Russian.
  • Um_nik and KAN for pre-reviewing the round!
  • MikeMirzayanov and KAN for creating and maintaining the amazing Codeforces and Polygon platforms!
  • You for participating in the round!

The score distribution will be:

$$$500$$$ — $$$1000$$$ — $$$1250$$$ — $$$1750$$$ — $$$2250$$$ — $$$2750$$$

Good luck, have fun, and may the rating be with you!

UPD: Congratulations to the winners!

Unofficial participants:

  1. abc864197532

  2. Rubikun

  3. maspy

  4. CryptoQuant

  5. Lynkcat

Official participants: (subject to change)

  1. Kodik

  2. sahajoydeep467

  3. Wonter

  4. jeduardobras

  5. Gemini17

UPD 2: The editorial is now available!

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

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

Auto comment: topic has been updated by Bufu (previous revision, new revision, compare).

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

as a tester, idk what to say but round is orz

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

Nice Score distribution!

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

I hope to solve ABC in this contest

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

    Solved A and B.. could have done C. But turns out I have to learn more. Good contest, had fun

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

      C becomes really simple with multiset, erase operation in multiset is O(1),

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

        Yeah, Ig I have to learn multiset again xD.. Anyway got C with some more tinkering and discussion with a friend

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

        Lowk priority queue >>> and also is erase really O(1) cuz I thought you have to go to the pointer then erase so its basically O(logn)?

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

          yes its O(logn), but if you want to erase a specific no and yk its index, then its O(1), like i used it to erase the first index, ofc you can use priority queue too

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

          Actually, erase(iterator) is O(1) amortized because the iterator already points to the element. Only erase(value) is O(log n) since it needs to search first.

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

I hope to become pupil in this round, or atleast solve ABC :D

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

hope complete ABC in D2

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

Hope to solve problem E!

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

As a Python beginner, two problems were hacked due to hashmap last round, hope this time won't be hacked.

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

Hope I don't get -16 on C this time

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

As a participant, I can fly

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

solve AB is enough wish me lucky

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

Can't wait to see my rating changes after this contest

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

I hope to solve most of them at, least ABCD

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

Hope to solve ABC plz GGGGGGGGGGGG

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

Upvoting this Comment is counted as a ritual for complating at least ABC. :D

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

Hoping to solve ABC. :)

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

hope to return 1400

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

Downvote me

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

I hope to cross 1500 in this contest :)

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

Hope to solve $$$ \gt 0$$$ problems ovo

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

Good luck to all participants!

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

why do not tester say "as a tester, ......." to get the upvotes?

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

Hey...

How to become the testers or problem setters in contest

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

Hoping that I don't go down to pupil again.

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

I really hope this is a good round.

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

Really hope to solve E this round.

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

as a participant i hope the contest will be easy>.<

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

manifesting solving at least 3 problems — will be back here after contest

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

hope to get +6 delta . Peace

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

i give up

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

Hardest contest I've ever done

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

HOLLLLLY STAR WARS REFERENCE. W Contest btw

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

I was one contest away from pupil and then, this contest...

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

guys, wtf was this contest? i sure need to practice but damn

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

Confirmed I'll be staying a newbie for a while

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

I give up

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

is it just me or the contest was too tough >:c

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

Why are problems D, E, and F so classic?

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

A>>>B

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

the taskpool seems unfair and unbalanced

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

problem E is really too good that i cant even solve

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

A bad problem.

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

A bad day that I had penalties on almost every problem T_T.

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

as a tester, i give up at A

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

I solved $$$C$$$ by doing:

  1. Sort elements of $$$a$$$
  2. Assign an $$$id$$$ to each $$$a_{i, j}$$$
  3. Iterate $$$i$$$ from $$$n$$$ to $$$1$$$
  4. Keep all elements in grid $$$[i, n][1, m]$$$ in a Segment Tree, based on their $$$id$$$
  5. Also keep them in an ordered_set
  6. Walk on Segment Tree to find first $$$id$$$ where suffix $$$sum \gt = v_i$$$
  7. Get the number of elements from the ordered set (size — index of $$$id$$$). This is $$$cnt$$$.
  8. $$$ans = min(ans, cnt)$$$

Submission

Please tell me this is not the intended solution.

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

    well it can be solved using priority queue and greedy approach . just try to find sum of smallest number of elements greater than than the smaller level[i]

    but yes i found b to be tougher than both a ,c

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

    I was thinking about doing that for a minute, but there is one extra observation: for each row of length $$$m$$$, you never need to check more than $$$m$$$ $$$a_{i, j}$$$'s since the answer is $$$\le m$$$ (we can just knock down a row with $$$m$$$ moves). So you can just store a heap of the $$$m$$$ largest $$$a_{i, j}$$$'s as you're going through the $$$n$$$ rows to do it in $$$O(nm \log m)$$$.

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

      Oh yes. It's kind of like Regret Greedy isn't it? We take all elements, regret it when our sum becomes too big, and them remove smaller ones.

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

        In this case it's not really regret greedy since our heap will basically be a static length of $$$m$$$ for each row (where we store the $$$m$$$ greatest $$$a_{i,j}$$$'s of all of the preceding rows including the current one). If the sum of those $$$m$$$ $$$a_{i, j} \ge v_i$$$, then great, we can process the $$$m$$$ elements and see if we can do better than $$$m$$$. If that sum $$$ \lt v_i$$$, then we don't care since it is given that we can achieve an answer of $$$m$$$.

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

      Do we have to enumerate all heap sizes less than m and select minimum heap size satisfying it ? That was my solution or can it be just solved with one pass ? I pop elements from min heap whenever total number of elements exceed target size for less than m. 1 <= target size <= m

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

        I'm not sure, but either way it wouldn't improve the overall time complexity. If you could do that, you'd probably have to use some complicated data structure.

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

    Notice that $$$ans \leq m$$$ where $$$m$$$ is the number of columns since deleting a whole row is an option.

    With this in mind, iterate from bottom to top, maintaining a priority queue (or sorted set), and try taking the greatest numbers at or beneath your current level, stopping at $$$m$$$ numbers.

    For each row ($$$n$$$), you access your priority queue $$$O(m)$$$ times so complexity is $$$O(mn \cdot log(mn))$$$

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

Used priority queue on A level question :D

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

I'm surprised that E isn't OEISable.

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

the contest was so hard for me, just I solved A

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

Problem A

1
15
1 1 1 1 1 2 2 2 2 2 3 3 3 3 3

output: 21

still passed all the pretests btw ✌

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

Hello during contest i faced an interesting "bug".

In Friends Standings i was 3538th at 18.59.27.

And in Common Standings i was 3023th at 18.59.30.

Does anybody know why this happened?

(Unofficials not included to standings.)

I can't upload video but for confirmation you can ask onepersonintheuniverse and amodi .

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

    Assuming u turned off the "Show unoffl",

    in common standings the ranklist is based on all official trusted users

    in friends standings it's all official users, regardless of whether they're trusted or not

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

Is it just me or B and C had easier observations than A?

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

Good problems, but I found testcases (especially for C) a bit poor

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

I solve problem A and B only in this contest...

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

Can somebody help me understand why my solution for B fails. I am not able to figure out a test case where it fails. I find the number of zeroes "z" and ones "o" that we need to remove which would result in a alternating string. Then as long as the number of zeroes and ones differ by at max 1 we can just output z + o. If They differ by more than that we can consider the singleton 1s and 0s at the edges of the string. Submission

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

    Consider a case like 00010.

    You aren't considering that deleting a character may bring two groups together.

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

      find pairs of 0s (say x) and 1s(say y). ex-> 000, means 2 pairs of 0s and so on.

      now if diff b/w pairs of 0s and 1s is 0 or 1. ans is x+y

      if it is abs(2), first and last digit comes into play. if zeros are more than ones and first OR last digit is 1, then ans is x+y+1

      if it is abs(3), first and last digit comes into play. if zeros are more than ones and first AND last digit is 1, then ans is x+y+2.

      is this approach ok????

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

    i am also using the same logic but failing idk why

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

Question A and C were amazing

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

is editorial out?

»
2 months ago, hide # |
 
Vote: I like it -6 Vote: I do not like it

Problem C in this contest is a nasty problem with strict constant-factor optimization requirements.

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

What was the approach for B? Are you guys too grouping consecutive 1s and 0s and writing their frequenciez in an array?

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

    find pairs of 0s (say x) and 1s(say y). ex-> 000, means 2 pairs of 0s and so on.

    now if diff b/w pairs of 0s and 1s is 0 or 1. ans is x+y

    if it is abs(2), first and last digit comes into play. if zeros are more than ones and first OR last digit is 1, then ans is x+y+1

    if it is abs(3), first and last digit comes into play. if zeros are more than ones and first AND last digit is 1, then ans is x+y+2.

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

I solved A through D, but only came up with the solution for F right when the contest ended. I thought it was a 2.5-hour round, but it turned out to be only 2 hours. So after all that, I ended up solving F after the contest. /fn /fn /fn

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

    But I feel F's solution is way more straightforward than E's.

    For E, you need to derive the formula and then brute‑force to spot the pattern — I definitely can't prove that.

    For F, centroids come to mind easily, then greedy, and finally virtual trees — it all clicks together step by step

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

for D ques Can anyone please tell me why my Maxheap priority queue solution is giving tle at test case 9 and how did you solved the problem

#include <bits/stdc++.h>
using namespace std;

#define int long long

void solve(){
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>>minheap;
    vector<int>caninsert(n,0);
    for(int i=1;i<n-1;i++){
        if(abs(v[i-1])%2==abs(v[i+1])%2){
            caninsert[i]=1;
            minheap.push({v[i-1]-v[i]+v[i+1],i});
        }
    }
    while(!minheap.empty()){
        pair<int,int>front= minheap.top();
        minheap.pop();
        int index=front.second;
        if(front.first>=v[index])continue;
        v[index]=front.first;
        if(caninsert[index-1]){
            int newval= v[index-2]+v[index]-v[index-1]; 
            if(newval<v[index-1]){
                minheap.push({newval,index-1});
            }
        }
        if(caninsert[index+1]){
            int newval= v[index+2]+v[index]-v[index+1];
            if(newval<v[index+1]){
                minheap.push({newval,index+1});
            }
        }
    }
    for(int i=0;i<n;i++)cout<<v[i]<<" ";
    cout<<"\n";
}
»
2 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

i wonder how many people will get WA2 on D because they didnt think about modulo of negative numbers. almost gave up on the problem before noticing it. fun contest though, thanks

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

who else was misleaded by a dp approach in C :-(

IF someone Really completed C using dp, plz share!

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

    I don't think there was a dp approach to C, I used a priority queue to keep track of optimal ones to use and went from bottom of tower to top to find min at each tower and keep min overall, note that the answer will always be min of that and m since by removing entire tower, it already topples

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

      dp[i][j] -> for rows i to n-1 what is the sum of highest j elements we can pick

      dp[i][0]=0 base case; and transition is what i really cant figure out

      ultimately if everything is fine -> our ans will be the min of all dp[i][j] such that dp(i,j) < (the min stability index from 0 to ith row)

      If interested, please find the transition and help me out

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

gng can someone tell me how to do A? I'm like stuck, i tried using a frequency table but I can't find what to do first :(. Brute force doesnt seem feasible at n = 50 either.

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

    Ideally we would like all equal frequencies, as in this case we can use all numbers available. To get towards this state, use the most frequent element, then the second most frequent element (while at least two distinct elements remain) repeatedly.

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

    consider the element with the highest frequency, lets call it max. if max<=ceil(n/2), then the answer is just the sum. because you can always pair up any number with a number that isn't itself. but if max>ceil(n/2), then you can notice that at some point you will be forced to put 2 of that number in a row (or rather if you are forced to make some amount of pairs then one of the pairs will have to be 2 of that same number). this is a pretty common idea used in many problems so its good to look it up and learn it.

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

    yall are actually my saviors thanks to both of you i solved it. any tips for getting better at cf overall?

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

      consistency and not being afraid to read editorials were the 2 main things that helped me improve. also do problems that are rated at about your rating+200/300. what are your goals?

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

        to acheive usaco silver/gold next season, im using codeforces to prep for it. also a rating of like 1300+ here would be nice.

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

          honestly I am not too familiar with usaco equivalents to like cf rating. so you're doing it to qualify for like irl competitions for usa or? I feel like each country has very different priorities and things they value in competitors so it really depends.

»
2 months ago, hide # |
 
Vote: I like it -26 Vote: I do not like it

worst div2 ever

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

    I disagree. I thought the problem quality was incredible. I personally didn't have the best contest and I know that if I didn't spend time checking the leaderboard I could have solved D and if the contest wasn't 2 hours I could have solved D but nevertheless I overall liked the problems. I somewhat had a false solve for A that costed me around 5 minutes and I think with 5 minutes I could have solved D and gained rating :sob: Second time failing to solve D when 97% done with the problem.

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

      That is your own opinion. I think this div2 was much harder than other div2s. I tried to tell my thoughts about the question difficulty by typing the worst div2 ever. But the problem quality was good. I don't know if it was just me but i asked my other friends who participated in this contest, and they also agreed with me. Maybe it is just i got a little rusty with not working daily because i was having a break. But i think this div2 was harder than other div2s.

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

      Yes any contest in which you solved 3-4 problems and you got not much minus rating delta for dont fall from expert will be incredible

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

        Not necessarily, I don't think that personal achievements in a contest should dictate the quality of a contest. I recently did a virtual of 1112 and I think I had a fairly good performance (I didn't bother to impl c and d) but I thought the problems were of somewhat low quality despite doing well personally on this contest. In this contest particular I appreciated how it wasn't a "speedforces" round as much to the problems being more difficult. Also in this contest I don't think I performed nearly as well as I am capable of, I was planning (hoping) to get to 1700 this contest and while yes I didn't drop off too much despite only solving three problems it was still a rather disappointing performance.

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

Very good contest! Although i didn't solve E or F, i really liked them.

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

Thanks everyone for participating in Codeforces Round 1115 (Div. 2). Although it was initially difficult to understand from the editorial when I first participating in Codeforces contests. However I found that once I got used to it, the explanations felt very easy to understand, accurate, and highly academic.

We should read the hint and solution before reading code (Sorry for my bad English)

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

The problem D is very interesting. It's a good round I think.

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

Hello,

I would like to clarify that I did not share my code with anyone and did not have access to any participant's solution during the contest.

The solution I submitted was written by me during the contest based on my understanding of the problem. The approach used is a fairly standard one, and it is possible that multiple participants arrived at similar implementations independently. I did not intentionally copy code from any source or participant.

If the similarity was caused by a commonly known technique, editorial-style implementation, or another publicly available resource that existed before the contest, then the overlap was completely unintentional.

I respect the contest rules and would appreciate it if the submission could be reviewed manually. If any additional information is required from my side, I would be happy to provide it.

Thank you.

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

Hello, I received a system warning stating that my solution for Problem 2252D significantly coincides with others. I just want to clarify that I didn't cheat, share my code, or use any outside sources. The similarity happened because the mathematical reduction of this problem basically forces everyone into the exact same standard implementation. During the contest, I realized that replacing a[i] with a[i-1] — a[i] + a[i+1] is really hard to track directly. But if you transform the array into a difference array where d[i] = a[i+1] — a[i], it makes everything way simpler. If you apply the operation, the new value becomes a[i]' = a[i-1] — a[i] + a[i+1]. When you calculate the new differences with this updated value, the left difference d[i-1]' becomes a[i+1] — a[i], which is just the old d[i]. The right difference d[i]' becomes a[i] — a[i-1], which is the old d[i-1]. So, the complex operation from the problem statement is literally just swapping adjacent elements in the difference array. The problem also says the operation is only valid if a[i-1] and a[i+1] have the same parity, meaning their difference is even. Since a[i+1] — a[i-1] is equal to d[i] + d[i-1], their sum can only be even if d[i] and d[i-1] share the exact same parity (both odd or both even). Because we can swap any adjacent differences that have the same parity, the optimal way to get the lexicographically smallest array is just to find contiguous blocks of differences with the same parity and sort them in ascending order. When writing this in C++, I naturally used a while loop to find the boundaries of these contiguous segments and called std::sort(). It's such a direct way to code this logic that my variable names and loop structures ended up matching many other participants who figured out the same math trick. I kindly ask the admins to review my thought process, as this was just a natural implementation of a deterministic solution, not a coordinated leak.

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

Hello,

I would like to clarify that I did not share my code with anyone and did not have access to anyone else's solution during the contest. I did not use any external help during the contest . During the contest i realised if two alternate numbers a[i-1] and a[i+1] have the same parity then the difference between a[i-1] and a[i] and a[i] and a[i + 1] will also have the same parity . Using the first and second test case i realised that if a section of difference array having the same parity is sorted , this will force the resulting vector to be lexographically smallest.

While writing the cpp code I used while loop to find the boundary of the same parity substring. Once the while loop ends i sorted that section in parity and moved to the next section.

i request admins to review my thought process during the contest as I have no other proof of innocence , i would also like to add that i use the default VSCode formatter while writing all of my code so that may also have enhanced the similarity to other submissions who may have done the same.

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

practised so many questions still not able to solve A

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

I received the plagiarism warning for my submission 385925201 (2252D) and would like to request a manual review.

I solved and implemented the problem independently during the contest and had no access to any other participant's code. A few days ago, I saw this youtube video and coincidently this question used a similar technique — Link (https://youtu.be/96RG7EBF8LI?si=k-KgX3StSScjr3L7), dated : 24 June, 2023. 

I understand that my code is very similar to other people who have solved it. However, I did not view their submission or copy from them. I had no access to their code during the contest. I have my original VS Code files/development history as evidence of my independent work, and I can provide them if required.

I would be grateful if the case could be manually reviewed. Thank you.