Hello, Codeforces!
I am very excited to invite you to our contest Codeforces Round 1059 (Div. 3), which starts on 17.10.2025 17:35 (Московское время). You will be given $$$2$$$ hours and $$$15$$$ minutes to solve $$$8$$$ problems.
The problems were authored and prepared by wakanda-forever, wuhudsm, tridipta2806 and frostcat.
Note that at least one of the problems will be interactive. So if you are unfamiliar with them, please read the guide for interactive problems before the contest.
The round will be hosted by the rules of educational rounds (extended ICPC). Thus, all solutions will be judged on preliminary tests during the round, and after the round, there will be a 12-hour phase of open hacks. After the open hack phase, all accepted solutions will be rejudged on successful hacks. Also, note that there is no score distribution — rank will be determined by the number of problems solved, followed by penalty; wrong submissions will incur the usual penalty of 10 minutes, following the rules of educational rounds.
Remember that only the trusted participants of the third division will be included in the official standings table. As it is written by the link, this is a compulsory measure for combating unsporting behavior. To qualify as a trusted participant of the third division, you must:
- take part in at least five rated rounds (and solve at least one problem in each of them)
- do not have a point of 1900 or higher in the rating.
Regardless of whether you are a trusted participant of the third division or not, if your rating is less than 1600, then the round will be rated for you.
We would like to thank:
- cry for beautiful coordination.
- shorya1835, Divine_Spark and Krishbansal333 for proposing problems that later weren’t included in the final set.
- Dominater069 for LGM testing.
- __baozii__ for red testing.
- Friedrich, mayank69goel, shorya1835, aastik231205, reirugan, Intellegent, 18o3, Ming_Xu, Proof_by_QED, efishel and Arpa for orange testing.
- Edeeva, Prady, friedel, Forge, macaquedev, pop and omegaphi for purple testing.
- RustyGrill, Eikyu, HackerGupta069, DivinePunishment, Darsh_Jain, expertaq, Kushi, Krishbansal333, kingbass and chromate00 for blue testing.
- Trace_X1729, sanju77 and Maroon5_sugar for cyan testing.
- santaclaus67 for green testing.
- MikeMirzayanov and KAN for the great platforms.
I wish you the best of luck, and I hope you enjoy the problems!








Auto comment: topic has been updated by wakanda-forever (previous revision, new revision, compare).
As an author, I hope you'll enjoy the problems!
As a contestant, i enjoyed the problems
what a beautiful contest.
Best of luck to everyone — hoping you all see a nice rating increase !
Problems are really cool… would suggest everyone to give this contest and hope you enjoy it…
very good last task, i liked it
Participate or you will miss some truly beautiful problems.
Possibly as beautiful as your pfp??
Possibly as beautiful as your name??
Seems like there will be a question named "beautiful array". Is it?
TRUE ;)
As a tester, I can confirm this problem set is "beautiful".
As a tester, I was forced to write an as a tester comment
Hi
Hi
As a tester, -. . ...- . .-. / --. — -. -. .- / --. .. ...- . / -.-- — ..- / ..- .--.
New rickroll type :)))
As a tester, I can confidently say that this problem set is beautifully designed — it’s genuinely fun and a joy to attempt.
As a tester, regarding questions I would say only one thing, think DP but apply greedy, or maybe vice versa, hope everyone has fun solving problem, all the best :)
Excited to participate and get some positive delta
Hey all these days I dont understand what is specific color testing and what they do in general ?
As a tester, I can confirm you’re gonna have a great time giving this contest. Don’t miss it!
As a tester, I made a video of solving all the problems. I'll put the stream very soon on Codeforces, don't miss it.
A contest with Interactive Problems , its going to be GREAT again
18o3 the tester OTZ
As a tester, the problems are really cool and fun to attempt. I hope you all have a beautiful increase in rating.
what about the recent decrease?(rollback)
All the best everyone! Hope everyone gets +ve delta.
As a participant , seems interesting.
Is cry's basement already full?
As a participant, SHAW!
cout << "Best of luck CODERS for this round!" << endl;
Be Ready for one INTERACTIVE Problem. there will be one.
Here is guide for Interactive Problems.
According to the poor situation of QueueForces's submission now, will it be rated?
really excited to give an unrated round after a pathetic performance in last round.
hope to reach lgm this contest
div.3 ❌ div.2 ✅
yet G has 1k AC
All — Beautiful
How beautiful the problem are !
ConstructiveForces
how to H?
Oh my god. Please ban all unrated participants, I almost shocked when I see the common standings.
Multiple valid answers everywhere
Please ban the Unrated cheaters
Do they influence our rating changes?
if u passed more than 6 problems, maybe no influence
It does for most of us
the interactive snuffed me out, i hate those questions
constructive forces
No way G went from 200 to 700 in like 5 minutes. Regardless a good contest.
Is problem D not just binary searching over smallest L and largest R, where the condition is checking if query "1 mid mid" yields a different value from query "2 mid mid"?
You will exceed 40 if you do binary search for both, it can be done using a single binary search to find L, and the R can be calculated using something else
see first find the length of the updated subarray, this can be done by doing 1st operation on 1..n let it be A and 2nd operation on 1..n, let it be B, now r-l+1= B-A. now do BS to find r. now we know r-l+1 value, substitute r their to find l, we cannot do BS on both r and l since it would exceed 40 operations.
Was E that easy? Please give some hints.
Id like some hints as well, got stuck in it for a long time. Tried some stuff but got WA on 2
make cases when there is 1 missing element in the array..when there is 2 missing elements in the array etc.
Yes what i did was if vector a has all the values from 1 to n, then just cout a[1] to a[k], else find the missing value. first cout that missing value, next cout a value not equal to missing value and a[n], then rest cout 1 to n excluding missing value and a[n]
lol what is this standing?
Why did no sample case for B have a solution with a subsequence rather than a subarray?
i feel your pain bro
Beautiful Permutation — Can someone help me in finding the issue with this code. I'm using binary search to find L and R.
see first find the length of the updated subarray, this can be done by doing 1st operation on 1..n let it be A and 2nd operation on 1..n, let it be B, now r-l+1= B-A. now do BS to find r. now we know r-l+1 value, substitute r their to find l, we cannot do BS on both r and l since it would exceed 40 operations.
This will take more than 40 queries , log2(2e4) is roughly 15 (14.28)
So in your case 4* 15 > 40
Instead find length using 2 queries by asking whole range sums from 1..n and subtract to get length
and r = l + (len-1) . L you can find using bs.
2*15 < 40
bro, i was just lost in life after failing C for like the 10th time, and then i read "u gotta use the current a not initial" pmo
So many bots! How will CF handle this? Will this game still be rated?
Really great problems. Enjoyed!
Open the status page, and set the filters as follows: Problem G, Verdict Accepted, Language Python3. Look at the submissions that were made just before the contest ended. All of them (literally ALL) are unrated (black) people, and the running time and consumed memory of those submissions are mostly uniform. I looked at some submissions and they looked all AI-generated. They are almost all cheaters.
Coordinators and admins, please look into them.
UPD: I've found that other problems are in the similar situation; generally Python 3 submissions are filled with cheaters.
Really sad to see my favorite platform getting ruined by cheaters.
theoretically shouldn't happen because set contains 1 and cover all sums 0..sum_rest, but if it does, skip this c and continue search I have never seen this type of comment being shared tbh
Hello, Constructiveforces!
CHEATFORCES Today,left after solving 4 problems at a ~3.5k rank came back and saw my rank to be 4.9k changed within last 12 minutes of the contest wow , so so many cheaters so annoying dont know how to keep myself motivated having these things
This is my code for problem C:
I need an explaination why it is wrong:(((( Anybody please help me:((((
Your code fails on the following testcase :
1
6 7
Your code gives output as -1 whereas one of the correct output is
2
1 0
Beautiful contest, we should have more mainly constructive contests!
344346152 344346149 344344898 344348892 344348159 344348061
What a coincidence that they have the same code and the same comments
how to prove that we always have a solution for problem G except when n=2?
is it related to pigeonhole principle?
You prove it by constructing a solution for $$$n \geq 3$$$
Video Solution of A,B,C,D,E with C++ code of Codeforces Round 1059 (Div. 3): https://youtu.be/ty5y1geayPI
I was doing hacking and got the following message
Recently, your account was used to crawl. Please change your password to prevent your account from being used for unauthorized activities.
what can i do to avoid it??
Cause till now i have made only 26 hacks (15 successful)
on the other hand i have seen people make 300+ hacks , is there any trick
You are right. Also i was doing hack. And same action happened.
And there is a good test case to problem B which given tle for some bitmask or python solutions.
Just look at the rank list from 150 to 400, a very high density of black people. Submission pattern so random. I think someone made bot to submit with so many account or maybe a very mass cheating group.
the standing looks so strange. so many unrated participants with high score.
so cool that hundreds of xxxxxxx people had a stroke of genius in a few minutes and completed A-G, and their solutions are exactly the same. in early time you can find that every page of top ranks are full of these fk guys
Any idea why this logic is wrong for E?
Submission
In a nutshell, I am appending an element that is different from last two distinct elements.
then for it , 1123 , now you add 1 ?? (why not add the element which was used quite early and just maintain doing it over all k suffixes ??)
We can do that, but I want to know what is wrong with my solution?
And from implementation and time complexity perspective both solution are similar
i tried a similar approach which was making sure that each addition neither created a length 2 nor a length 3 palindrome, but for example if k = 1 and you have arr = [321112]
picking an element different than the last 2 elements (1 and 2) can cause you to pick 3 which would create an extra length 7 palindrome (a better answer is either 4,5, or 6).
Ahhh Finally, Makes sense!! Thanks!
I ran into this same idea. Imagine you have [1,2,3,2] for n=4. 1 adds a palindrome, and 4 doesn’t. My solution was to brute force the first 3 elements to find the least amount of palindromes, then repeat that permutation for the rest.
As a Contestant, I still don't understand interactive problems. But very nice questions.
thanks for the contest!!!
Is Codeforces planning a roll back due to such obvious and impactful cheating?
I AGREE
I dont get it why my solution does not work, WA on testcase 2/53, can somebody have a look? Thanks
345461995