Hello, Codeforces!
After years of hard work, we are euphoric to invite you to participate in Codeforces Round 1077 (Div. 1) and Codeforces Round 1077 (Div. 2), which will be held at 29.01.2026 17:35 (Московское время). For both divisions, you will be given $$$7$$$ problems and $$$3$$$ hours to solve them. For at least one of the divisions, one of the problems will be divided into two subtasks.
The problems are invented and prepared by Bronya_H, Error_Yuan, StarSilk, Tobo, __baozii__ and me.
We would like to thank:
- SSerxhs for his Superb, Stellar, Extraordinary, Reliable, Xcellent, Helpful and Supportive coordination.
- Alexdat2000 for Russian translations.
- zeemanz and bookcat for providing some ideas that were not ultimately used.
- cry for inventing a basement of infinite capacity to imprison cheaters.
- errorgorn, tiger2005, EnofTaiPeople, and dXqwq for black opal testing.
- geospiza, Aging1986, Sugar_fan, Duck_sajin, qkm66666, AYTDD, Fantasy_Blue, Intellegent, SATSKY_2025target_LGM, _istil, wangmarui, rucaco, fallleaves01, permutation, nifeshe, and A_G for ruby testing.
- Proof_by_QED, sh1ziku, 0x3F, K_tian, aori., sszcdjr, hxu10, CirnoNine, and chennie for topaz testing.
- fatalerror, Fusu, -WIDA-, shendeliliang, and Liang_SYEA for amethyst testing.
- Kato_Shoko, TEYL, clearlove13, Non-origination, chromate00, fr200110217102, and XiaoXia for sapphire testing.
- imhighshou and Clclclcl for aquamarine testing.
- MikeMirzayanov for his obsidian Codeforces and Polygon platform.
The score distribution is below.
Div. 1: $$$750 - 1250 - 1750 - 2000 - 2250 - (2000 + 3500) - 3000$$$.
Div. 2: $$$500 - 1000 - 1500 - 2000 - 2500 - 2750 - 3000$$$.
We sincerely hope you can enjoy the problems. Good luck and see you on the field !
UPD1: The hacks are disabled for problems A-D in Div 2, and for problems A-B in Div 1. We have final tests consisting of pretests and hacks for all problems.
UPD2: Editorial








First!
Orz
Orz
Orz
Orz
Orz
As a participant, I believe this round will be the most exciting one.
As not a tester, neither of these contests will require the ability to speak Chinese to AC
I love __baozii__ and -firefly- and fatalerror so much that I’d even have their babies!
Yes, I can prove it.
Aha, that reminds me of that funny picture which described you're hugging your baby who's on the wheelchair.
Salute to The God Yiren!
God Yiren
I participate div2 at the first time...
No 6-7 meme this time :(
6-7?
My honor to participate in testing work again with those brilliant coordinators and testers. GLHF!
PS: A photo of __baozii__ and -firefly-:
As a tester, I wanted the authors' QQ numbers.
0x3F orz !
The hype for -firefly-'s crossdress cosplay is real!
As a Ruby tester, I have no idea for using Ruby.
Tester. A wonderful round, enjoy it!
Chuffed to be a tester. A meowvelous round. Hope you find the problems as sweet as an apple : )
As a tester, I wish everyone good luck! :)
As a participant, i really hope to reach CM
Good luck everyone!
excited
Tester list bigger than my solved list.
Cry knows what's coming GL, everyone. I hope it goes well!
ready to hopefully inch closer to pupil!
.
As a tester, I lose the chance to acheive grandmaster.
Hello!
Huge respect to the setters and testers. Excited for the round
The score distribution will be announced later, along with my crossdress cosplay photograph.

what am i doing here?
How to be a part of this?
As a tester, I think that problems are interesting, have fun!
Glad to become one of the testers for this round! I wish all participants GL and HF!
Yeah I barely become a black opal tester on the list ;)
Typical LGM :)
As a tester, I know that he just moved all cheaters on room $$$n$$$ ($$$\forall n \in \mathbb{N}$$$) to room $$$2n$$$ on his last coordinated contest.
what does cry do when he encounters an uncountable number of cheaters
He'll have to expand his basement yet again
Hilbert's Hotel moment :)
I hope it goes well.
Hope this round deserves an emerald upvote.
As a participant, i really hope to reach Expert
Good luck everyone!
Orz
time came to enjoy specialist rank again i guess
GLHF!
is there late registration ?
SSerxhs StarSilk Error_Yuan My account Jin-li-han was disabled mid contest, i had provided clarification for my fast solves for A,B,C to the authors which was due to my laptop crashing and disconnecting from the monitor due to the new nvidia drver updates. for which i had to do a clean reinstall and restart my laptop. in the time being i had paper solved A,B,C and had started on D, I fell i have been banned because it was my first cf contest. however if you have any issues regarding my solutions or any suspected ai use i am more than happy to provide my workproduct and thought process if it is simply becuase of me being a new account i request the ban be reverted for this is unfair towards me. i have not used ai or any other external resources or done anything which violates in contest rules. kindly look into this
This is only my 3rd contest, and I haven’t been able to solve a single problem in this one. Does anyone have advice on how I can improve?
You should practice more 800-1200 rating problems and vp div 3,div 4,div2edu to improve yourself,div 2 is a challenge for you now and they are relatively easy.Pick up the algorithm you can't figure out when working through practice problems.
I don't think div2edu is easier than div2...also I think learning basics is more important
what are the basics?
I think like simple greedy, dp, search, and data structures.
Also some necessary math knowledge.
Honestly, I’m not sure what problems to practice. I usually go to the problemset, filter by 800 rating, and start solving. If I get stuck, I try for another 15 minutes, but often still can’t solve it. I’ve only been on Codeforces for about 10 days, and I’m trying to practice every day as much as possible. Do you have any other suggestions? It would really help me a lot.
Follow cp 31 sheet by TLE eliminators
Problems are so bad. SpeedGuessForces.
Fun fact on Div1D: You need to remove duplicates before take the modulo of each cool number. I hate pretest23, letting my score minus about 200. And why Chinese round don't have super large samples on data structure problem. I continue getting RE TLE MLE on Div1C.
Huhh!! Sort of GuessForces, and I just suck at bitmask DP
Nice Div2B
Enjoyed the contest!
F1 should never exist in any contest.
Seeing the trend from last 4 div1 rounds; one can probably bet on the fact that next Div1 round would also contain a problem on Trees.
look forward to the tutorial
When will it be out?
so excited to see editorial for E didn't solve it for almost 2 hours
Use HLD. But it can also be solved without it.
for B ,any hints ??
Let's find p's which can be an answer, after that for each p we will try to find optimal q.
Oh thanks , will upsolve ^-^
Why my submission for B is wrong can anyone tell me ??
Submission link : https://mirror.codeforces.com/contest/2188/submission/360537624
When a player stands on a vertex v, it is always optimal to move to the maximal vertex u, s.t. v->u exists. Let's build a tree with only optimal edges, the answer will be the sum of dep[y]-dep[lca(x,y)] over pairs of vertices x,y with dep[y] <= dep[x]. By fixing lca(x,y) and using dp on subtrees on depths the problem is solvable in O(n).
Wow this beautiful approach
Amazing experience really good problems
F2 is an old ICPC india regional problem, but constraints were cubic.
The idea of my solution of problem Div2D\Div2B (I realized it too late sadly :( )
there are four cases of the solution
$$$p = x$$$ and $$$q$$$ is the first valid number greater than or equal to $$$y$$$, $$$(q \ge y)$$$
$$$p = x$$$ and $$$q$$$ is the first valid number less than or equal to $$$y$$$, $$$(q \le y)$$$
$$$q = y$$$ and $$$p$$$ is the first valid number greater than or equal to $$$x$$$, $$$(p \ge x)$$$
$$$q = y$$$ and $$$p$$$ is the first valid number less than or equal to $$$x$$$, $$$(p \le x)$$$
from each case, find the best pair that minimizes $$$|x - p| + |y - q|$$$
a valid number is any number that holds the condition $$$p \& q = 0$$$
Yeah I observed that too by brute forcing over all p and q , but how to find the appropriate p and q? Any hint pls
Think of brute force then try to optimise it using dp.
I'm not sure if what I wrote are hints or the actual answer, but read them and try to implement them by yourself ^_^
for the second and fourth cases
set all the bits that are not set in the other number in the pair, where with these set bits, the number is less than the given number
in the second case, set all the bits that are not set in $$$x$$$, and make sure you stop when $$$q$$$ becomes greater than $$$y$$$ (and remove the last add)
in the fourth case, do the same but with $$$q$$$ and $$$x$$$
for the first and third cases
set all the bits that are not in the other number in the pair until you reach $$$2^{31}$$$, then start from the highest bit, remove it if the result is greater than the given number, leave it set if it will become less than the given number
in the first case, set all the bits in $$$q$$$ to the 30-th bit (starting from 0), unset any bit that is already set in $$$x$$$, then start from the 30-th bit until the 0-th bit, remove it, if the result is greater than or equal $$$y$$$, continue, otherwise add it again and continue
the same in the third case with $$$p$$$
I hope that you found them useful ^_^
Thats very clever, thank you! I will try it
Bro I do same but still wrong answer, can u check
your way to find the lesser number is correct
but your way to find the higher number is not always true
if I have the number 12, in binary it is 1100, let's say that the next higher number is 1101, while your solution finds that the higher number is 16 10000
Wow, i regret looking at the tests more carefully :'(
Took >3hours and lots of debugging to implement this case based approach.
I observed this solution as well after submitting ~30 submissions :(
I was doing ,
If the bits of x and y is different then we can take the bit's of x in p as it is and same for the y bit's in q as it is ,
but if they are different we have to make either q's bit 1 or the p's bit 1.
But couldn't come with a dp solution during contest otherwise would have been my first div2 D.
Finally implemented
How do you solve div2 D ?
My guessforces answer is as follows:
we can guarantee x will remain unchanged or y will remain unchanged..
can you greedily find the other number such that the abs difference is minimal and & is 0?
Did the same getting wa on test 2?
Maybe your greedy wasn’t greedy enough
That was a excellent contest ! Thanks
editorial??
wonderful contest to be honest
Pretty easy and previously seen question b was seen as div3e somewhere in past splitting across 1 c was pretty easy simple two elements can make it at right position idk I found a more difficult than usual a's
There’s no way we got more than 7000 ac in div 2 problem C
Honestly, once you catch whats going on its pretty stright forward problem.
QAQ
So, the Indian guy at the top of the ranklist(div 2) has 6 compilation errors and 10+ WA on pretest-1 in just a single contest? Definitely not a cheater I guess.
My solution for Problem D: https://mirror.codeforces.com/contest/2188/submission/360633363
Cool problem C! I did(n't) solve it during contest, but its solution is actually very satisfying. The first thing I noticed is that there's monotonicity in
k(ifk+1works, so doesk). "Ok", I thought, "perhaps I'll use that later." So I set that fact aside and continued thinking.(1) Then I considered how swaps work and if I could somehow exploit the condition. I noticed it's possible to swap
(x, y)using some otherzsuch thatzstays in place. This would contributemin(abs(x-z), abs(y-z))instead ofabs(x-y). Seemed useful enough.(2) Another idea I had was to treat this array as a graph and add edges between nodes (array indices) if their values had an absolute difference
>= k. That is, if I were to binary search.Since I did not see how to put to use (1), I decided to follow the advice of a wise man I once learned. "All you need is randomly guessing."
(3) So I guessed that if I grouped nodes from (2) together (union-find), it would be possible to somehow sort them within these groups. Also, notice we do not need to merge all of them. It's enough to merge a node
xwithmin(instead of some prefix) andmax(instead of some suffix) (when possible).And... it WA'd. Only after the contest did I realize why. I set my right binary search bounds too low! I forgot I wasn't dealing with a permutation! Ouch!
So after the contest I had a conversation with my friend NekoIie, who arrived at this powerful observation:
k=min(k, max(abs(a[i]-min_element(a[])), abs(a[i]-max_element(a[]))amongithat are missplaced. This is to say that it's always optimal to swap with eithermaxorminin the array.I did miss that! And then he pointed me to the right construction. Imagine we are binary searching (in the end we can ommit this). Find the positon of
a[i]in the final sequence (denote the element present there currently asmp(i)(short for "mapped"). Break ties in some sensible way. For some fixedk, we will traverse the arraya[]and (skipiifa[i]is already in the right place) if it's possible to swap, do so. Otherwise, try one of the following constructions: (A) useminto swap(i, mp(i)). (B) usemaxto swap them. (C) useminANDmaxto swap them.So, in the end, we always pick either
minormaxfor someiand perform the swaps. This also proves the approach described in (3). Because there will be some middle part left out and a connected component of some prefix and suffix. I wish I went a step further during my attempt at solving the problem and considered the implications of my idea. At the very least, I'd write a shortercheck()for my "magically" working solution!This comment is meant to serve as a reminder that among all the moving bits and pieces in a problem, it's always useful to first try find elements that don't change much, that are maximal or minimal in some way. After you "grab" hold of them, try to reason and progress from there. That helps a ton. It's fairly similar to solving math problems with invariants and monovariants. A different wise man once said "when solving a problem try to think of the smallest sensible step that could lead from your current position to the solution". Because solving a problem is like fiding the right path through a graph (of ideas).
360627538 — the clever construction (could be written even more concisely, since after all, you just pick to swap with
minormax, also one (abs(y-x)) of themaxterms could be removed, it's never worse to not use it and I should probably mention that I don't actually do the swaps ina[], although it could be done, works regardless)360628478 — corrected random guess here
We can solve d2D/d1B using simple greedy method!
Traverse from MSB to LSB.
Till the point where either only x has a set bit, or only y has a set bit, add those bits to p or q respectively.
First position where both x and y shares a set bit, we need to decide to whom we should allocate this bit. Let it be allocated to "p".
Note that doing this, we miss out the set bit of "y" which also needs to get subtracted to minimize the overall result (but one position can be present in only one of the number, either "p" or "q", as p&q = 0). So, to compensate this loss in "q", we will add all the remaining positions till "0" with 1's to "q", and won't fill "p" afterwards. For, "q" it's better choice (instead of waiting) as, $$$2^x \gt 2^{x-1} + 2^{x-2} + ... + 2^1 + 2^0$$$. So, no matter even if we fill all remaining bits with 1's in "q", it still can't completely nullify it the effect of "1" that was left out on the left side.
But this isn't always optimal for "q", sometimes instead of filling remaining bits with 1's. It's optimal to set p = x (or q = y depending on what is chosen as "x" and "y") and for q we will remove all the ones from the first position from MSB where "X" and "Y" shares common set bit, and find first place from this position in the left direction where both "X" and "Y" have unset bits and add this position to "q". This can be seen in last test case.
My submission: 360631214
https://ibb.co/1tvfLNrM How is this possible? I dont get it
Enjoyed the contest !. Though i solved AB during the contest, After giving a thought to the C, I regretted because i solved B very late and had i got more time during the contest, i could have cracked the C one. I think i need to keep my practice high so that i don't just solve the problem but solve in less time as compared to my competitors !.
honestly the tasks are difficult
Let's go, one point away from expert
Задача G никто не мог решать
First!
hello
when will the editorial be released?
https://mirror.codeforces.com/blog/entry/150649
It has been released long ago. You can also see at the bottom right of the contest dashboard (under Contest Materials).
breh
Good round!
I am not first!
I also!
Ok!
(deleted)
deleted
this round learnt that short problem statement does not mean problem is easier..
If anyone wants a dp solution for div 2 D :Problem Link
Here is my code:{If explanation needed , ping me} .
Please Eliminate NguyenQuyetDinh2.cpp
He cheated in last round
The F's submission https://mirror.codeforces.com/contest/2188/submission/360593590
Good Very Good
Hi, coordinators
A coincidence warning was sent to me regarding issue 2188C (contribution 360598939).
I did not steal anyone's code, did not share my code with anyone, did not use public online IDE with open access.
The code appears identical because several participants (including me) independently adopted the same faulty greedy idea:Calculate the overall minimum and maximum. - if sorted already → -1 If not, take min over max's misplaced places (a[i]-L, R-a[i]).
When you mistake or misunderstand the swap condition, this is a perfectly natural incorrect thought. apart from that my code snippet is like that in this particular maximum part from the snippet. You can observe that numerous false submissions on B have almost the same format. I have submitted 5 wrong submission for b three before and two after submitting the c i have to copy i would have done it for b before doing c it's just that the solution clicked me.
This, in my opinion, is an instance of numerous individuals making the same error on their own.
Please check / cancel the warning if feasible.
I'm grateful!