Hello Codeforces!!!
We are delighted to invite you to participate in Codeforces Round 1095 (Div. 2), which will be held on Apr/28/2026 17:35 (Moscow time). You will be given $$$7$$$ problems, including one split into two subtasks (not necessarily placed adjacently), and $$$2$$$ hours $$$15$$$ minutes to solve them. This round will be rated for the participants with a rating lower than 2100.
The problems are authored and prepared by wakanda-forever and wuhudsm.
The scoring distribution is as follows:
| A | B | C | D | E | F | G |
|---|---|---|---|---|---|---|
| $$$500$$$ | $$$750$$$ | $$$1500$$$ | $$$2000$$$ | $$$2500$$$ | $$$2500$$$ | $$$2500$$$ |
We would like to express our sincere thanks to the following individuals for their contributions and for making this round possible:
- Proof_by_QED for his incredibly indelible coordination.
- Um_nik for preliminary review of the round.
- Alexdat2000 for Russian translations.
- Our testers: A_G, awesomeguy856, -firefly-, Dominater069, sammyuri, liympanda, IceKnight1093, physics0523, nik_exists, SpyrosAliv, Argentum47, DivinePunishment, omsincoconut, __baozii__, Edeeva, chromate00, shorya1835, AksLolCoding, Friedrich, simplelife, tridipta2806, _istil, expertaq
- MikeMirzayanov and KAN for the epic platforms.
- And finally, you for participating.
We hope you take part in the round and enjoy solving the problems. Good Luck and Have Fun!
UPD: Hacks will be disabled for the problems A to E.
UPD: Editorial
UPD: Congratulations to the winners!!!
Top 5 overall:
Top 5 rated participants:
First solves:
- A: Od_Ali
- B: longago_06
- C: 2002chenhan
- D: SATSKY_2025target_LGM
- E: Nachia
- F: Golovanov399
- G: A10ne









Auto comment: topic has been updated by wakanda-forever (previous revision, new revision, compare).
As as tester, testing this round allowed me to test the testing of tested rounds which were tested by testing testers
As a tester, this round tested me
I'm not a tester.
you're a tester (of an LLM model)
Then what's your purpose in life
Auto comment: topic has been updated by wakanda-forever (previous revision, new revision, compare).
obligatory tester comment.
I also tested
All cheaters will face the punishment shown in wakanda-forever's profile picture
As a tester, I was forced to post a tester comment. So I decided to post the most cringy one I could think of.
You are righr, but Genshin is a great game.
You're right, but Genshin Impact is a brand new open-world adventure game independently developed by miHoYo.
wuthering wrong answer
As a tested tester , I procrastinated at the problems for at least 67 minutes.
Wow it's very hintive that the score of E,F,G are same...
Are you serious?is that meaning their difficulty are identical.It's lack of probability.
Anyway,hope to get more rating!
I'm not a tester, so this is purely speculation. But based on the announcement, one possibility is that G is a supertask of a prior problem (since there are non-adjacent subtasks). In this case, it would stand to reason that G is much harder than E and F, despite the same scores.
Hopefully, the problem statement will be short and precise just like the announcement
Seeing same scores for E, F and G imply that G is definitely a subtask (hard version).
May I know that what was the purpose to give problem G the same points as E and F?
All cheaters will face the punishment shown in wakanda-forever's profile picture
10/10 would test again
As a linger, I usually go to sleep early.
The problem statement should be given more clearly.
are there interactive?
No. If so, it would be announced.
Hope it is gonna be fun unlike the last spectral cup!
Auto comment: topic has been updated by wakanda-forever (previous revision, new revision, compare).
why no extra registration? :(
There is extra registration, however, it was closed 5 minutes ago.
Back in my day extra registration never used to close. Weird times we are living in
that's just educational/div3/div4
me too hha
the problem A was very funny. ._.
How did more than a thousand people solve D, even tho E looks easier, and D looks way harder than C?
problem C is quite interesting
Please if someone can give hint for C :)
Solve Problem E first.
It is the biggest mistake I have ever made in my life (or i just bad at implementing segments tree)
No I will do G first. I will do it easily
If you can achieve a mex m > 1, then you can achieve m — 1, hinting towards a binary search solution.
Problem G >>>
C >> D
Auto comment: topic has been updated by wakanda-forever (previous revision, new revision, compare).
https://mirror.codeforces.com/contest/2226/problem/A Solution : Take all 1s and the last number if it's not 1. Then take every single index one by one. This is the most optimal solution.
https://mirror.codeforces.com/contest/2226/problem/B Solution : Good subarray can only be of size 2 and difference of numbers is equal to minimum.
https://mirror.codeforces.com/contest/2226/problem/C Approach : For every i calculate the maximum mex you can construct from it and then make a sorted list by inserting a new maxmex on every iteration. And also make one list with index of each. Finally, for every i from 0 to size. Iterate the sorted list and find the first value smaller than or equal to i or if any index contains the i value itself then increase i by 1. Repeat until we reach size or end of the sorted list. i will be the maximum mex.
https://mirror.codeforces.com/contest/2226/problem/E Idea : How to calculate for every prefix quickly? We can keep track which index converts to which number(mex) in the array. Let's call it the tracking array. What if we calculate the tracking array for the whole array first then start deleting last index and keep updating the tracking array accordingly to get the maximum mex?
$$$C$$$ is good, but how to solve $$$E$$$? I was thinking something using Segment Tree to set and get prefix maximums and do some greedy pairing? Like try to pair $$$i$$$ with element $$$i$$$, or another smaller element and so on?
What was the solution/ idea for C had a lot of ideas none of them seemed to Work out
One key observation of x%y <= x/2, so can think of greedily pairing numbers for a particular mid value of binary search.
Hint for C, please. I tried a greedy approach, but I don't think greedy would work here. DP may work. My greedy solution was: for every possible $$$\text{MEX}_i$$$ where $$$i \in {0, 1, 2, \ldots, n}$$$, I would check what the options are for $$$\text{MEX}_i$$$. The options were either the same element as $$$\text{MEX}_i$$$, the element $$$2 \cdot \text{MEX}_i$$$, or some larger integers. Greedily, in my first attempt I prioritized the first option over the second, and in my second attempt I reversed the priority. Neither worked.
You are on the right track kind of. First you can find the current of mex of the array easily. Then obviously you need to make the mex out of the array. So picking the smallest number that is equal to mex or greater than twice of mex is the optimal way(of course we can't choose the already chosen index). and then just keep repeating till you cant.
Editorial has been published.
Problem titles are interesting. Thanks for the contest.
I did c by binary search got idea fast but implementation took time
for given mid
Note max (mex-1 ) is mini(n-1, max+1)
iter map reversly from large to small till > mid
all elements x > mid they can be used to fill for elemnts < (x+1 / 2 ) -1 store this in an array p[(x+1 / 2 ) -1] = map[x]
available_replacement = 0 now iterate from mid to 0 if element already exists or use from counter
and update counter + p[i] also we can use if more elements present update p[(i+1)/2-1] = m[i]-1
available_replacement + = p[i] if we can reach till zero then it is possible
heres my solution
https://mirror.codeforces.com/contest/2226/submission/372870212
i should have gotten the idea for E earlier :(
cf contests without cheaters is such a delight...no inflated solve count
how are there no cheater? i mean is something different?
in india people have their end sem exams going on(sorry to say but major chunk of cheaters are from india) ... which is why there are less participants too
Huh, i was wondering why the scoreboard seems weirdly "normal"
cool will give lot of contests now, to go back to normal.
I've spent 2 hours on C, but for some strange reason the output in the cf tester differed with the output in my IDE. Like sometimes the tester would give me WA on the first test, although I would get the correct output in my IDE. In an online compiler I also get the correct answer. What can be the reason for that? I also asked it during the contest, but did not get an answer
Made a fun use of subproblems (C & E) today to save some time and score.
After solving C, when solving E, we can first write a quadratic solution, print the last answer instead of the whole array, and submit it as problem C to check correctness.
Now, if it got OK, the score for problem C would suffer. However, the outcome won't be OK: it will be either WA if the logic is wrong, or TL if the logic is right until the larger tests come. So, it's a free check to save some testing time.
When we get TL instead of WA, we can proceed to speed up the quadratic solution, now most surely right but slow, using the data structures. And then submit it as E.
Which rating change extension are you using? I’ve been using the Carrot extension, but it hasn’t been working for the last two contests and keeps showing an error:
I think C is much more difficult than D.After solving A,B and D,I spent all the rest time on C and got nothing besides "-5".Maybe I am too stupid.
Auto comment: topic has been updated by wakanda-forever (previous revision, new revision, compare).
By the way, my arm was broken)
Carrot, Repovive's Predictor and even CF Predictor are completely dead. Someone in the comments of one of the prev blogs told me that the "probrat" command from Limak Discord bot is also not working. Anyone got a working alternative?
MikeMirzayanov and the Codeforces team, I am writing this comment to appeal against the plagiarism flag on my solution 372871538 for problem 2226C. I believe this is a false positive. The approach I used — binary search on the answer combined with a greedy check — is a completely standard technique for MEX-type problems that many contestants naturally and independently arrive at. The fact that 200+ solutions were flagged simultaneously strongly suggests that the plagiarism checker has detected a common algorithmic pattern rather than actual copying. My code was written entirely by me during the contest. My personal template with my name (TheAlgoForge) is clearly visible at the top of my submission, which I believe reflects that this is genuinely my own work. I did not share my code on any public platform such as ideone or pastebin at any point during or before the contest. I also want to be transparent — I noticed my greedy implementation had a bug (using the largest available element instead of the smallest valid element > 2x), which may have ironically increased structural similarity with other contestants who independently made the same logical mistake while thinking through the problem. Codeforces is a very important platform for my journey as a competitive programmer. Every contest and every problem means a great deal to me, and I would never compromise my integrity by cheating. Being flagged for something I did not do is truly disheartening. I sincerely request the admins to review this case carefully. Thank you for your time and consideration. — TheAlgoForge
My submission 372847551 for problem D recently got flagged for similarity to 372859404. I believe this is purely a coincidence: I do not know such user and have arrived to the solution and implementation completely on my own, without any kind of external help. I also exclusively used local IDEs, and there is no way another person could possibly have access to the code. I have a screen recording of the entire contest, which I would be happy to provide. I kindly request to review the case.
I am writing this to the codeforces team and the contest team. I was recently plagarised for my solution of problem C. I want to say that this is purely unintentional and i didn't take any help from anyone and solved the problem on my own. My solution id is 372850530 and it matched to a lot of solutions more likely a similar concept in solving rather than cheating. I hope the codeforces team will look into the matter. I am adding my brief approach.
So the whole point of the problem is trying to max out the MEX of an array using modulo operations. When I was dry-running the math, the main moment was realising how the modulo actually restricts us. Basically, if you want to turn some number x into a target y, you only have two options: either it's already exactly y (and you just take a massive mod so it doesn't change), or you gotta shrink it down. If you are shrinking it, the math works out so that you absolutely need x >= 2y + 1. That single condition basically carried my entire logic.
Ngl, my first instinct was just to code a greedy approach from the bottom up, trying to secure 0, 1, 2, and so on. But I ended up getting a WA on one of the test cases. When I debugged it, I realised my code was acting way too greedy. Like, to form a 0, it would just snatch up a 2 because it fit the formula. But that 2 was literally the only exact match I had for the target 2 later on, so I totally griefed my own sequence and cut it short. To fix this, I completely pivoted to binary searching the answer. By guessing a target MEX, I instantly know exactly which numbers I need to hoard. So the final logic is: lock down the exact matches first so they don't get wasted, dump all the leftovers and duplicates into a "spare pool," and then just pair the remaining missing targets with spares that fit the x >= 2y + 1 vibe. Since I sort the array right at the start, the checking function runs in linear time, making the whole thing a super clean O(N log N).
hhh