Ciao, Codeforces! We're glad to invite you to take part in Codeforces Round 1066 (Div. 1 + Div. 2), which will start on Nov/23/2025 12:35 (Moscow time). You will be given 9 problems and 3 hours to solve them in both divisions. The round will share some problems with The 2025 ICPC Southwestern Europe Regional Contest (SWERC) 2025.
Note the unusual starting time.
Some of the problems might be interactive, so please read the guide for interactive problems if you are not familiar with it.
The problems were authored and prepared by KLPP and me.
We would like to thank
- Dominater069 for his 💭 💡 🎈 coordination;
- Alexdat2000 for Russian translation;
- dario2994 for VIP testing;
- Geothermal, MrBrionix, xiaowuc1, SmolBrain, awoo, Intellegent, IceKnight1093, MridulAhi, Adam_GS, A_G, Sana, Virv, ha___il, chromate00, beaten_by_ai for testing;
- {Rafi22, surgutti, Krzychuo}, {Akulyat, arzhantsev64, okwedook}, {AlperenT, izhang, Extile} for team testing;
- the SWERC judges team for judging the problems;
- MikeMirzayanov for creating Codeforces and Polygon;
- dario2994 for creating pol2dom, a tool to convert problems from the Polygon format to the SWERC format with minimal effort.
The score distribution will be announced after the onsite contest starts.
We hope you'll like the problemset!
UPD 1: The score distribution is as follows:
$$$500 + 1000 + 1500 + 1500 + 2000 + 2500 + 3000 + 3750 + 4000$$$
UPD 2: Upsolving & viewing of solutions and tests will be closed until the end of the onsite contest (13:30 UTC, 1 hour after the Codeforces round ends). Please also refrain from discussing the problems in public until that time.
UPD 3: Congratulations to the winners:
- Rank $$$1$$$ : tourist
- Rank $$$2$$$ : jiangbowen
- Rank $$$3$$$ : ksun48
- Rank $$$4$$$ : PEIMUDA
- Rank $$$5$$$ : Radewoosh (Only solve on problem I!)
- Rank $$$6$$$ : VivaciousAubergine
- Rank $$$7$$$ : qiuzx
- Rank $$$8$$$ : Rinne_qwq
- Rank $$$9$$$ : Rubikun
- Rank $$$10$$$ : maspy
UPD 4: The editorial is out.








As a tester, I found one problem in this contest very nice, and recommend you to participate.
Yes I feel the same. The problem set is great and recommended to several participants
Only one?
only one?:(
as a commenter, I commented very fast.
This is one of the most funny comments I have ever seen
That is true
please share the score distribution
That would be a spoiler for the onsite contestants (SWERC has no score distribution).
😭 😭
🤥
Wait, you mean, NINE problems within just THREE hours? This is really kind of ICPC style qwq.
I wanted to comment that typical ICPC contest should have 10-15 problems so actually judges had to remove something from the set (and this is usually the case). While trying to verify that, I found https://icpc.global/regionals/rules that states:
Which means technically a Codeforces div2 round with A-F problems might be held as a regional? That's funny.
it's div 1-2 for this reason
Touch glass
Will people like me lose rating from div1+div2s?
Problems A-F in div1+div2 is about the same difficulty with div 2 (sometimes even easier, especially D) ,so you'll probably get a +rating if you solve A-D within 1.5h or A-E within 3h.
Is it rated? IAKIOI
GG
Yes!
Those who jc (use somebody else's account to do something bad) others will have such a bad luck that he or she would even not be able to solve A.
As not a tester, I think the problems in this contest are very nice, and recommend you to participate. :)
Yeah, a really kind star time to Chinese.
I agree
I'm pretty sure that the onsite contest already started, where's the score distribution
The onsite contest starts 90 minutes before the CF round.
Seems like I must've looked at the wrong website
What abt now, where is it?
Can you publish it now plz?
As a tester, I want to know why you're not playing Honkai: Star Rail.
If I reach 2300 FIDE Elo at chess within October 2025, I will start playing Honkai: Star Rail :))
[deleted]Will the problems still be in rough difficulty order or random like ICPC?
They will be in difficulty order.
As a tester , I feel that the contest is great and I recommend to participate
I trust you. Don't let me down
What sort of difficulty should I expect?
I've just started on this website (yesterday) and have enjoyed my time so far.
Just wondering how hard this is going to be on a difficulty scale.
You can check previous Div. 1 + Div. 2 rounds (for example, Codeforces Global Round 30 (Div. 1 + Div. 2)) for reference.
What is the difficulty of this problem? This is my first time getting an email and I don't know if it is very hard or very easy.
give it a try!
If i don't get Cyan today, strap me up.
Good luck you guys
fml
Ouch, just 2 points off
I've been to 1399 before, so it doesn't hurt
As a participant, I did not read that this contest starts a little early. As a result, I will now be doing this on mobile in chemistry class.
As your chemistry teacher, I will provide you with a computer.
First time learning about interactive problems! I know div 1 and div 2 is out of my reach for a newbie, but I shall try my best!!
Lucky enough to look at the unusual timing just 1.5 hrs before the contest
btw can I see the live scoreboard for SWERC somewhere?
We will make it public when the CF round starts.
Make sense, thanks!
Where is the hacking-disabled zone for this round?
The contest starts in 4 minutes. GLHF guys!
As a human, I am a human
cool B
I got stuck on it sadly, only started with an hour left in the comp but I breezed A but B felt like going round in circles.
why is my solution being skipped while the contest is still live
This user is disabled

I am wondering what they did...
Didn't do anything just attempted G question Stop this psychotic happiness
Why such attitude towards others. Doesnt make sense. I didn't cheat Go check my submissions
Upsolving & viewing of solutions and tests will be closed until the end of the onsite contest (13:30 UTC, 1 hour after the Codeforces round ends).
Please also refrain from discussing the problems in public until that time.
Just saw this. We will cancel solution discussion. Thanks for pinging me.
I deleted my comment because it felt like snitching.But I posted it again.
I think Shayan is starting problem discussion 5 minutes after codeforces contest ends.
No haha. If you would not mention me, I probably wouldn't understand and the solutions would be discussed. Thanks.
You are welcome
oh
Uh missed the contest..should have looked at the unusual time :(
Me too buddy. Guess we'll just have to accept our negative delta
You don't get negative delta from not submitting anything on a contest you're registered on.
But one submission, be it WA, TLE or AC and you're done
Does WA on pretest1 still count?
just curious
No, it doesn't as a wrong submission. But, I think it counts as participation (source: me)
Didn't know about it and I'm glad is that way. Thanks a lot!
Is there a rating-predictor in Codeforces?
there is a chrome extension named 'carrot'
Works on Firefox too
Where?I didn't find it...
big +delta for me, I like it
that is a huge delta!
thanks, I was hoping for a bigger one though xD
Congratulations to becoming Candidate Master!
thanks, im just getting back to it tho
really awesome b ; i couldnt properly impelement the solution to c , for 2nd time in my life i solved c 2 min after the contest ended :(
C is rubbish
yes,i tried it for two hour
certainly
I am happy that
pretest = system test... as I came up with some construction and it was correct .. but got cooked byDjust because you couldn't solve it? funny
humorous.In fact,I wouldn't say it is an interesting problem even if I solved it.But I didn't.So I can just say you were right.
why?? it was hard no doubt but why rubbish?
I don't like this problem.That is my opinion.Of course someone think it is not.
Fun fact: I also independently submitted a problem that was almost the exact same to D to propose for a Codeforces contest. It was turned down :p
The contest was really amazing. Thanks for arranging such a nice contest.
Fun problemset!
This is a bit awkward to ask everyone to do (specially since it's an announcement not many people will read). Wouldn't it be better if the round happened 1 hour later then? Were setters just not available at that time?
My first time in a div1&2 contest
E<D
turly
Negative because I implemented a stupid binary search on segment tree.
Btw E<C even so.
I solved A-F today,
the most advanced data structure I used is map<int,int> on problem A,
the most advanced algorithm I used today is sort() on problem D.
I know. I just want to show how stupid I was.
How to solve E?
It's not that hard to see that this problem is easier to do with a frequency map.
From observations you can get that when, for some $$$i$$$, $$$f_i \gt k$$$, then you have to move $$$f_i-1$$$ drones from energy $$$i$$$ to $$$i+1$$$, so basically $$$f_{i+1}:=f_i-1,f_i:=1^{(1)}$$$ ($$$:=$$$ means assignment).
Let's define a chain reaction when $$$f_i \gt k$$$, and we advance the drones of $$$f_i$$$ to the right (thus incrementing $$$i$$$) until $$$f_i≤k$$$, leaving a trail of $$$1$$$s behind. At the end, if we started from $$$s$$$ and ended at $$$i$$$, the total number of operations that chain reaction did was $$$i-s$$$. Let's save all trails of ones in an array $$$jump$$$, in the format $$$jump_s=j$$$.
Any chain reaction passing on an existing trail of $$$1$$$s (which starts on position $$$j$$$) will, after $$$jump_j-j$$$ operations, continue from $$$jump_j$$$ without changing the trail (ofc it will leave it's own trail of $$$1$$$s, but $$$1=1$$$, so the elements of $$$f_{j:jump_j}$$$ won't change).
So, our answer to the problem will be the longest chain reaction. Of course, every chain reaction has a constant rate, so no chain reaction can "catch up" to another ongoing, which means it's safe to simulate chain reactions from the right, to the left.
This means we can have a variable $$$s\in{2n,\dots,1}$$$, and we can check if $$$f_s \gt k$$$. If this is true, we start simulating the chain reaction from $$$f_s$$$, with $$$(1)$$$. If we get to $$$i$$$ where $$$jump_i$$$ is set, we can skip a lot of indexes, which saves runtime and reduces energy consumption, thus slowing down global warming. At the end of the chain reaction, if the length of this chain reaction is the largest ever, we save it ($$$m:=max{m,i-s}$$$).
Implementation: codeforces.com/contest/2157/submission/350326830
Appreciate the starting time.UTC+8 is a timezone that is very difficult to participate in usual contests for high school students.Will CF hold more contests at different starting times?
Same. Here on UTC+9 most of the contests starts at 11:30pm.
about F and G: sorry I'm not your GF.
the type of fumble I do when I'm 9 away from expert. Did well in my ICPC region too :(
check mine!
ak+q is great!
For Problem G, it seems easier to guess the solution than to prove it. The real challenge is mustering the courage to implement an idea you’re uncertain about.
You can do some metagame and realize that the solution is "optimal", in the sense that you cannot do better (if the array is fixed), then the solution must be correct.
proof by trust me bro.
That's true.
So true lol
But writing a checker actually doesn't take any time, so a possible approach is to write a simple checker yourself and test every single idea to see how they perform.
Where can I see onsite standings?
F. G and H are both non-traditional questions that catch people off guard, and there are some random distinguishing elements for participants with scores less than or equal to 3000.
Really makes you stand up from your seat, find a pen and paper and do university-level combinatorics & statistics
wtf H brute searching is correct
so shocked, so what's the intended solution
The intended solution uses that $$$p_n$$$ must be large if $$$n-m$$$ is small. You seem to use that accidentally in your brute force.
can someone suggest me the fix for C on top of my solution, thanks!!! https://mirror.codeforces.com/contest/2157/submission/350367577
Will this round be another case for this?
Edit: Seems that it has been fixed now.
C+D > F
When will the editorial be released? I look forward to reading it.
Is there anybody who used ternary search for problem D?
It would be O(nlog(n)^2)
why so?
I did O(logn) solution by first sorting the guesse then pairing and seeing a certain condition wrt l,r. It gave me correct ans.
Apart from a task on BalkanOI 2024 test day, I've never heard of a task with ternary search required. Use binary search on the difference.
I can assume that my method cannot be solved with binary search, because my result is based on maximizing answer. If to look at my code, it's clear ternary search without any idea .You can see my code below. 350340059
In your code, how do you traverse $$$i\in l,\dots,r$$$ without TLE?
in the end of the loop r-l is not more than 3
Can anyone help me with a testcase why am i wa on test 5? https://mirror.codeforces.com/contest/2157/submission/350344325
Probably you have to sort the mex intervals by their left boundaries? I see your code is similar to mine, and I mistakenly assumed that the intervals are in order so filling the mex intervals might be problematic (e.g., three mex intervals overlap with each other, and we filled the first and the last before filling the one in the middle). Didn't really look into the details tho, just a guess.
i have filled the values greedily, Lets say — k=3, and interval is (3, 5) and (1, 4). So first i will add the values in (3, 5). Next when filling values for (1,4) i will check which all values are already there in this interval. In this case index 3 and 4 are already filled with 0 and 1 respectively. So I just need to add 2 in index 1 for completing interval 2.
Let's say that the mex intervals are (1, 2), (2, 3), (4, 5) and (3, 4), and k=2. Then, if we fill the first 3 intervals greedily, we get [0, 1, 0, 0, 1], and we can find that when we fill (3, 4), we have no spare room to fill. So if the mex intervals are not in order there are some issues.
Thanks bro
when will editorial be available
During contest, For problem E, I went in wrong direction. It is very easy with monotonic stack. Probably easier than problem C or D.
https://mirror.codeforces.com/contest/2157/submission/350385547
No frequency map??
frequency map is required.. we just have to traverse this frequency map and maintain monotonic stack. I shared a solution. let me know, if you want more explanation on my solution.
Does anyone have spare time to explain F to me? I thought of sqrt decomp ($$$250000=500^2$$$) or cbrt decomp ($$$250047=63^3$$$). Unfortunately, the closest I got is 15 million robocoins, with the cube root. I don't ask for mathematical proof (99% I can prove it myself), but the idea.
Asking because I underperform in reading other people's code (aka suck at it)
My solution uses $$$~9.5e5$$$ operations.
Split number segment $$$[1, 250000]$$$ into blocks of size $$$100$$$.
$$$[1, 100], [101, 200], [201, 300], \dots$$$.
Let's do following operations: $$$\dots, (201, 1), (101, 1), (1, 1), \dots, (202, 1), (102, 1), (2, 1), \dots, (203, 1), (103, 1), (3, 1), \dots$$$. This way level will become divisible by $$$100$$$. We will spend $$$250000 + 1000 * 100 = 3.5e5$$$ operations.
Now split remaining numbers into blocks of size $$$100$$$ again.
$$$\{100, 200, \dots, 10000\}, \{10100, \dots, 20000\}, \{20100, \dots, 30000\}, \dots$$$.
Let's do the same thing: $$$ \dots, (20100, 100), (10100, 100), (100, 100), \dots $$$. This way level will become divisible by $$$10000$$$. We will spend $$$3.5e5$$$ operations again.
We have $$$25$$$ numbers remaining. Let's solve them trivially from smallest: $$$(10000, 10000), (20000, 10000), (30000, 10000), \dots$$$. We will spend $$$250000 + 1000 * 25 = 2.75e5$$$ operations.
isnt that 9.75e5 (roughly)
but if u actually count it should be lower by a bit (iirc)
Why is splitting by dividing by 100 the best solution
Like shouldn't dividing by 2 the best solution
I thought about converting all number Divisible by 2 Than divisible by 4 And so on till 1024
After that from lowest to biggest (1024,1024) , (2048. 1024), each will cost 1024 + 1000
But was able to get a solution of 2e6 coins
I use the cube root too.
Split $$$[1,250000]$$$ into blocks size of $$$64$$$ is enough.
Looking at your code. How did I not think of this… I was so close.
I also had the idea to put everything at multiples of $$$63$$$ (you did on $$$64$$$, but close enough), but the way I did it wasn't cost-efficient. I did $$$(i,64\left\lceil\frac i{64}\right\rceil-i),i\in250000,\dots,1$$$
Could anyone share me some problems that similar to D? I was stuck at D for nearly 2 hours because lack of greedy proof
Why in D, statement is written very very confusing??? "After you decide how to deal with all the offers, the actual Billion Players Game is played." After that i started solving the problem thinking first you decide, then value in [L, R] is given. BUT it was oppsosite and very easy ):
https://mirror.codeforces.com/contest/2157/submission/350358558
Can anyone help me in proving the correctness of this for today's D? I reached the solution through an observation by plotting on Desmos but can't prove why it works.
more people , more use of AI .. less people , less use of AI
hi it was nice contest
Hello, I received a similarity warning for my solution in this round. I did not share my code with anyone or copy from anyone. It is possible that I once used an online IDE that unintentionally made my code public. I understand this is against the rules even if unintentional, and I sincerely apologize. I will make sure this never happens again. Thank you for checking.
@MikeMirzayanov @Codeforces_Team Urgent: My account [AlgoMaster1] cannot view any solutions. Other accounts work fine. Cannot write blog post (no rated contests). Please check account restrictions. Thank you.
Regarding solution 350335303, I did not intentionally share my code. I will be more careful in future contests. I truly respect the terms and conditions of codeforces. Thank you.
Does anyone have the same problem like me? I can see all submissions before Codeforces Global Round 30, but in a few recent rounds, I am not allowed to view any submissions. Even I can't view my own submissions. Is this a bug or a feature?