Hello, Codeforces! 👋👋👋
Codeforces Round 1032 (Div. 3) will start at Jun/17/2025 17:35 (Moscow time). You will be offered 8 problems with expected difficulties to compose an interesting competition for participants with ratings up to 1600. However, all of you who wish to take part and have a rating of 1600 or higher, can register for the round unofficially.
The round will be hosted by rules of educational rounds (extended ICPC). Thus, solutions will be judged on preliminary tests during the round, and after the round, it will be a 12-hour phase of open hacks. After open hacks all accepted solutions will be rejudged on successful hacks.
You will be given 2 hours and 15 minutes to solve the problems.
Note that the penalty for the wrong submission in this round is 10 minutes.
Remember that only the trusted participants of the third division will be included in the official standings table. As it is written by 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.
I would like to express my gratitude to:
Vladosiya for the excellent coordination of the round.
Sugar_fan for red round testing.
Egorov_Dmitriy, katzi, KotlechkovEgor for purple round testing.
Chugunov_Alexander, itz_pabloo, IceHydra, NicoRobin, OutrunMyGun, gbula for blue round testing.
_supersonic_, ne_justlm for the cyan round testing.
MikeMirzayanov for Polygon and Codeforces systems.
Good luck! 🔥🔥🔥








hoping to get positive delta!!! (from a warrior race)
Hope to reach Specialist And complete my goal one month earlier In the bottom of the table....
Same) Btw I am there too
Hope this will be a great round :XD
So, it won't be rated for participants like me, as I have only participated in 3 rated rounds!?
Oh, sorry, I've missed the bold line
Only two div. 3 people tested?
Don’t worry it is probably ok because the non div 3 people were div 3 once too (probably)
hope to reach $$${\color{green}{pupil}}$$$
$$${\color{cyan}{and}}$$$ $$${\color{orange}{good}}$$$ $$${\color{red}{luck}}$$$ $$${\color{purple}{everyone}}$$$ $$${\color{blue}{!!!}}$$$
P.S: not today :(
same
hoping to get positive delta!!! (Recover from last Div 2):)
haha, check my prev div 2
rise again fall again , better rise again !!!
heheheheheheheheheheehehehehe
Don't make D too hard__
Hoping to reach a specialist in this contest.
same
Hoping to keep a specialist in this contest.
1401 is so danger lol
yeah, it's sounds more furious to keep than reach. hahaha
Hoping to solve 5 questions for the first time.
.
ha bhai badhane specialist nu keta keta expert thy jay tu
Score distribution?!?!?
1-1-1-1-1-1-1-1
HAHA GOOD JOKE
Hoping to reach specialist in this round
i hope it goes well
Hoping to become a pupil :3
As a tester, I have a proof that upvoting this comment will lead to positive delta. But the proof is too long to fit the margin.
Just don't make D harder than E.
hoping to 1. not get a minus rating change 2. reach pupil 3. solve 3+ problems in this contest(my best record is 2, A and B)
Is that round also can suit for people that unrated? Or i need to wait for div.4 round?
Omg finally my first unrated div3
Good luck to everyone! Hope to reach Cyan and no one enter cry's basement in this contest.
Hope to become div 3 unrated in this contest
hope to reach pupil
As a tester, I wish you all good results on this great round!
Hoping to reach pupil this time
First ever contest, I don't know shit about anything
welcome to codeforces
A very Warm Welcome from my Side!
Welcome on Codeforces Hi!
good luck everyone
Yo! This is going to be my first contest!
let's gooooo!
hope to reach pupil
Wish both of us will reach pupil
I just want 5 AC in this contest.
expect to expert
My first contest! Wish me well
The internet in Iran is terrible due to the conditions I hope I don't have any problems posting.
When I tried to upload my solution to the 3rd problem I got a "Sorry, you have been blocked" message. I tried and it is now blocking sending in solutions for previous competitions too. I tried to find info on the "help" page, but nothing useful. Anyone know whom to write to, and/or why this would happen?
bruuhhh div 3 also becoming harder
Contest with perfect level wise problem
Good contest, had fun!!
how to solve D
if u know bubble sort the problem becomes super easy, that is doing swaps of adjacent elements and passing it through the passes as many times as req to sort the array, just apply this process on array a and b and then just count the number of elements which are greater in array a and swap it with corresponding element of array b
wait seriously nvm then, i did a similar thing where i sort the array like this:
but somehow got wrong answer in the contest, so i just assumed im going beyond 1709 operations. turns out it's just a slight mistake in the code -_-
Sort both arrays using bubble sort, then if a[i] > b[i] swap. I was able to prove this during the contest. 324898354
Use bubble sort , one thing i found more useful is
normally we say that bubble sort takes n^2 time complexity but in real it takes max (n)*(n+1)/2 in question n was max 40 so for the both the arrays this will pass
initial i thought that 2 (for both array )* n^2 (i assumed that bubble sort is n^2) operation will need and i was confuse to solve it later i realized bubble sort requires less then n^2 operation
it is very very good problem , you can check my submission
actually im really just more worried about going beyond 1709 operations. Bubble sort did immediately come to mind but won't it take like n*n-1 oh my fuckin god i forgot to divide by 2!!! i forgot to divide by 2... that's why i thought max operations might take 40 * 39 * 2 = 3120 -_-
did anyone else do a randomized solution for $$$E$$$?
One of the nicest contest I have been in, my first time solving 5 problems in a Div 3 round.
so its nice if u solved the problem , otherwise bad lol
such a boring and uninspiring round. i felt like i was doing a codechef round smh. had the solution for F just couldn't be bothered to write it. i really dont know how any problems from C-F were accepted as actual problems, really disappointing
HOW TO SOLVE C?
For every row and column, keep the count of maximum element in it. If you are able to find such r, c such that max_count[r] + max_count[c] — (a[r][c] == max_element) is equal to total count of max element, you can reduce maximum by 1, otherwise you cannot.324845173
Beautiful problem H!
Doesn't it feel very standard if one knows how to solve LIS in nlogn.
Was it just me or was C more difficult than D and E...
for me D is harder than E F G H
why? I thought it was pretty easy to guess bubble sort would work operation wouldnt exceed 1709
most people including me thought that bubble sort won't work since it tc is O(n*n) so upper bound in total operation will be >2*n*n which is greater than 1709 later realized that it take at most n*(n-1)/2 ops so from now onwards upper bound will be n*(n)
yeah d was just bubble sort
I think I won't be able to participate in the codeforces contest until further notice The internet speed here is terrible and it takes 5 minutes to get to any page (due to the war) Goodbye codeforces!
nah top 100 div 3 of this contest, 70 cheaters, 30 smurfs
hope all AI-cheaters will get banned
Couldn't figure out why this fails on test2 in F: https://mirror.codeforces.com/contest/2121/submission/324900759
Mine too is failing:
https://mirror.codeforces.com/contest/2121/submission/324969264
Idea is it maintain a inverted fenwick tree on max as I iterate from left to right.
And then do binary search over indices.
Is there a solution to E without dp ? If so please explain it If not can u explain the dp solution
Not sure what the dp solution is. I did it as follows:
Start comparing digits of l and r from most significant to least significant and find the longest common prefix. The number x will need to have the same digits here. If the length of this common prefix is p, then 2*p is added to ans.
Now for 1st mismatch in digits of l and r, if digit.r > digit.l + 1, then we can construct x with no more common digits to l and r. In this case 2*p is the final ans.
Otherwise, there are 2 cases:
So ans = 2*p + min(q+1, r+1)
A purely greedy / constructive solution in O(number of digits): 324911040.
I solved it without dp It wasn't a hard problem but there were a lot of small points! I hope this code helps you:
n is the number of digits and res1, res2 are the input numbers that I received as strings
see my Solution Purely Greedy we st
Solution to E purely greedy 324948524
Here is my solution using DP. I am not sure if it is optimized properly, but it got accepted.
The goal is to minimize:
f(l, x) + f(x, r)We solve this using digit DP. The DP state tracks:
xrelative tolandrDP State Definition
dp[i][d][s]: Minimum matches wheni: Current digit position (from most to least significant)d: Digit placed at positionis: Current state ofx:0: Equal tolonly1: Equal toronly2: Equal to bothlandr3: Strictly betweenlandrBase Case
At the most significant digit
p:l[p] == r[p], we initializedp[p][l[p]][2] = 2l[p] != r[p], we initialize:dp[p][l[p]][0] = 1dp[p][r[p]][1] = 1(l[p] + 1, r[p] - 1), setdp[p][d][3] = 0Transitions
Loop from position
i = p-1down to0, and try all digit/state transitions:From state
0(equal tolonly):0if current digit isl[i](add+1)3if digit> l[i](add+0or+1if digit also equalsr[i])From state
1(equal toronly):1if digit isr[i](add+1)3if digit< r[i](add+0or+1if digit also equalsl[i])From state
2(equal to bothlandr):l[i] == r[i], stay in2and add+20if digit isl[i](add+1)1if digit isr[i](add+1)3if digit is between (add+0)From state
3(strictly between):+1if digit matchesl[i]orr[i]Final Answer
Minimum of all values
dp[0][d][s]over all digitsdand statessImplementation Code: 324944536
I enjoyed solving problem E and F, great contest
Problem G : codechef
this is actually crazy, might be the worst div3 i ever participated in
found C to be harder than D and E.May be ,I tried broote force
Had a lot of fun with problems F, G, and H. Thank you!
On a separate note, my solution to H was with lazy segment tree. Could somebody please tell me a cleaner idea? And, apart from that, my G uses three segment trees (well, four to be precise, but that was because I went crazy there for a sec), so a cleaner idea would also be appreciated.
I did G as follows:
Define a function g(l, r) as the minimum of frequency of 0 and 1 in s[l...r]
f(l, r) + g(l, r) = r-l+1 It is easy to find summation of f(l, r) $$$-$$$ g(l, r) over all (l, r). For the given string, keep a prefix array p with p[i] = number of 0's in s[1...i] $$$-$$$ number of 1's in s[1...i].
f(l, r) $$$-$$$ g(l, r) = abs(p[r] $$$-$$$ p[l-1]).
The rest is just computing sum of abs(p[x] $$$-$$$ p[y]) over all (x, y) which can be done by sorting p.
For problem H: You can extend standard LIS algorithm for this question whose implementation is very simple (just 3-5 lines of code using multiset).
Submission link: https://mirror.codeforces.com/contest/2121/submission/324947588
Great
I have a small doubt in understanding the problem statement, for k=2 do we need to consider just {a1,a2} or {{a1,a2},{a2,a3}....} set of all subarrays of length 2 ?
We only need to consider prefix of original array for each k. If k = 3 then consider only one subarray [a1, a2, a3].
I have a divide and conquer solution for G
max(a,b) = (a + b + |a - b|) / 2, now a + b is length and |a - b| is absoulte sum of diff in ones and zeros, now to calculate for every subarray, lets use divide and conquer, partition by mid and now we need some O(n) or O(nlogn) solution to calculate the abs sum of diff of those subarrays whose right end point lies from (mid + 1 , r) and left endpoint lies from (l,mid) which is easy to calculate since you can sort the diff array from l,mid and find prefix sum over that, code should make it more clearMy solution was fully inspired by yours — I learned a lot just by trying to understand it.
But I didn’t fully understand what’s actually going on in the divide and conquer part.
But, but, but... I think I’ve come up with a version that’s better — or at least easier to understand !
You used this formula:
That gave me an idea — why not just start by adding the total sum of all possible substring lengths, which is:
Then I realized, we just need to add the sum of all absolute differences of the prefix balances, which reminded me of a classic LeetCode problem —
“Sum of Absolute Differences in a Sorted Array.”
So even though I didn’t directly understand your approach, the idea you shared still helped guide me in the right direction. Thanks for that!
Here’s my code: 325253633
I think Vicfred cheated in this contest. He cheated in past contest, i wrote a blog about it.
https://mirror.codeforces.com/blog/entry/143816
I bricked problem F with sparse table and binary search... Turns out I don't have enough time sadly.
The quality of problems is getting worse day by day. Not a single problem were interesting.
A B AND C had no ideas u just read the problem and figure out the implementation , specially that C one i couldn't figure out how to implement the code for 1.5 hours xD
bad div
For problem F, can someone explain why am I getting TLE with this code though I used binary search?
vll vec = mp[need]
This is the reason it gives TLE. Use vector <$$$ll$$$> & vec = mp[need]
324934522
vll &vec = mp[need];
This is the only change you need to do, you need to access vector by reference, otherwise it will take O(size of vector) time to access the vector from the map, using &, you can do it in O(1).
why does this approach for F not work? what to change in this to make it work? Submission
You brute forced over all candidates, which is $$$O(n^2\log(n))$$$. You could use binary search to reach $$$O(n\log^2(n))$$$.
We can also remove that one log(n) factor. 324973026
thanks, this is an interesting approach
where exactly do i use binary search here though? wouldn't i have to iterate through all [l, r] to find out which range satisfies my query (max = x)?
You can binary search on the condition $$$max \lt x$$$ and $$$max \leq x$$$.
Problem G was nice!!!
Good Contest!!
The first div 3 contest that went good : )
My first div3!! Looks I need to work on my implementation skills. Able to find core idea of solution but not the right way to implement it. Enjoyed the contest nonetheless.
me solving F be like I need sparse matrix no wait there is no need.no wait I need it,ohh yeah it can be done without spare table
exactly same here, wasted a bunch of time because of lacking experience.
It can be solved by sparse table or without one also can. I've done both but... after contest))
why am i still unrated :(( newbie problem
It didn't update my rating either despite the blog saying, the round would be rated for below 1600 regardless of being a trusted participant or not?
i guess it was unrated after all :((
I dont think the ratings have been rolled out yet. Mine hasn't updated, and I am eligible for rated contests now
Same Problem despite me being shown in official standings
Hacking phase just finished. Rating will get updated in few hours.
Any body complete F with two pointers and hash map? My submission: 324893774
I have register for this contest and my rating is below 1600. I am able to solve one problem but my rating is not updated(not even negative delta).I can see people ,who didn't solve anything, on leader board . I have register this contest as rated only . Am I doing something wrong ?
No you are doing nothing wrong. You may not be able to be on the official standings as you have to attempt 5 contests successfully. As for rating change, wait for few more hours it will get updated. They haven't been rolled out yet
why the contest rating have not made any changes in already existing rating of mine? is the issue with someone else as well, it is not even showing in the graph as well
you have to wait for the system testing to finalize the rankings then it will be reflected on your account
Some of these cooked me ~
Something wrong in the contest its showing Current standings and even though the contest ended yesterday and it is displaying the previous version of it.
When do we get div-4 contest ,since it was expected to be held in the current month??
Can anyone help me with C ?
The idea is this: consider the maximum value in the grid, call it $$$X$$$, and look at all of the cells which have value $$$X$$$. If it is possible to choose a row and column that encapsulate all of these cells, then that becomes the optimal choice and the answer is $$$X - 1$$$. Otherwise, the answer is $$$X$$$.
There are a few ways to do this; the important part is NOT writing a $$$O(N^2M)$$$ or $$$O(NM^2)$$$ solution. If you do, you'll TLE to test cases with large $$$N$$$ or $$$M$$$, respectively.
My solution takes advantage of one property: assume that we can encapsulate all of the cells containing the value $$$X$$$. Pick any one of these cells (it doesn't matter which) — we will have to use either its row or column in the optimal choice. Assume we use its row; consider the set of cells with value X not on this row. If they all belong on the same column, it works. Otherwise, it doesn't. Swap the rows and the columns for the other case. Since there are at most $$$NM$$$ cells containing the maximum value X, this solution runs in $$$O(NM)$$$ time. You can check my solution for implementation.
You can actually pass an O(NM*min(N,M)) solution because of the constraints. Here's my submission
https://mirror.codeforces.com/contest/2121/submission/324849659
True, $$$NMmin(N,M)$$$ is no more than 1e5 ^ 1.5 so it will pass
My approach was the same as the one you mentioned in the first paragraph, but I couldn't think of a better logic to implement it.
Instead, I just decreased all the elements in the row and column by 1 and then searched for the largest number in the matrix.
I solved 3 problems and i remember seeing the third problem as accepted, but now it shows "In queue" Is there something wrong? Also, the ratings haven't been updated for my account either. Should i reach out somewhere?
Wait for the system testing to complete. Once it's done, you will be able to see your correct progress.
Cool. Thanks. I'm a little new to Codeforces so wasn't sure if it was regular behavior
why it is taking lot of time for system testing?
Div 3 often takes time due to the large number of participants
Why is it taking too long for system testing?? Just test those who are official participants :(
Pretest case should be more strong enough for problem C.
Hi Folks,
This is my first contest ever and at the moment I am unrated. I solved 6 out of the 8 questions in this round. Can I expect some kind of rating after this?
Thanks
Na , u can not expect
you'll be receiving a penalty because you cheated during this round using AI... really well done dude
when will ratings of this round will come??
Such a nice contest it was in terms of the problems given. Hopefully, I also got what I aimed for.
hoping to get positive delta!!!
here after long time , has cf changed something? i am not able to view other code for submissions.
You still can; just go to the leaderboard, find a user's row, then Ctrl + click on a cell in that row to see the results. From there, you can click once more to find the original submissions.
I think the two hacks I made on C were test cases 9 and 10... and holy moly so many people got TLE on 10. I'll take it :)
Unable to upsolve G if u can anyone explain the approach
when is the editorial coming?
its already up. Dont know why the author hasn't given the link, but this https://mirror.codeforces.com/blog/entry/143822 it the editorial.
voventa why no thanks to 74TrAkToR?
when will we get the tutorials?
tutorial posted here
ok thanks
problme -c
can anyone help me debug this code?
i wanted to stick to the logic of max in each row , col and their count.
Competitive Programming in 2025 – A Broken Race?
Two coders. Same leaderboard.
Result?
The problem: CP is turning into a “pay-to-win” model.
Impact:
The spirit of CP is at risk !!
The ask: Platforms like Codeforces, CodeChef, LeetCode must act fast. Cheating isn’t just breaking rules — it's breaking the community.
Let’s keep CP clean. Let’s keep it fair. Agree or disagree?
Appeal for submission 324913320 – Problem 2121F **** Hi Codeforces team,
I was recently notified that my submission 324913320 for problem 2121F has been flagged for plagiarism due to similarity with other users' solutions.
I want to clarify that I do not know the other participants involved, and there was no sharing or copying of code. I wrote the solution completely on my own during the contest.
The approach I used is based on a common pattern I've seen in similar problems on platforms like LeetCode, so it's possible others used a similar idea. That might explain why our code structures look alike.
I did not use any public IDEs (like ideone with public access), and I didn’t upload or share my solution anywhere.
I really value Codeforces as a platform and always try to follow the rules. If needed, I’m happy to explain how I arrived at the solution or provide my thought process to support this.
Please consider reviewing this again. I genuinely did not engage in any dishonest behavior.
Thanks for your time, SLASH_27 Submission ID: 324913320
Dear Codeforces team, I would like to clarify the reason behind the similarity between the solutions submitted under the handles mohamedhamdy4490 and hamdymo_93 for Problem 2121C. I was using two different accounts, and I submitted the same solution from both without realizing that doing so would be considered a violation of the contest rules. I had no intention to gain an unfair advantage or to engage in dishonest behavior. It was a mistake on my part due to a misunderstanding of the rules, and I now understand that such actions are not allowed, even if the same person is operating both accounts.
Hello Codeforces team,
I have received a message regarding the similarity of my solution (ID: 324907250) to problem 2121E with many others.
I want to clarify that I did not share my code with anyone, nor did I copy from any source. I only wrote and tested my code using the CodeChef IDE directly on a problem page (https://www.codechef.com/problems/SUPINC) using the default "Run" feature. I did not save the code, and I was unaware that simply running it on their platform might make it publicly visible.
I now realize that this might have unintentionally exposed my code to others. I sincerely apologize for this and assure you that it was not intentional. I will strictly use only private or local IDEs for all future contests.
Thank you for your understanding.
(Handle: 2023eeb1258)
Hello, Codeforces Team. I am writing to respectfully appeal the plagiarism judgment on my solutions for problem 2121E (submission 324872446) and 2121G (submission 324893225) from the recent contest. I was very concerned to see the notification that my code was flagged for similarity with user Srishanth_07. I want to explain the reasons for the similarity. For Problem E: My solution is based on a very standard Digit DP on a range [L, R] template. The state dp(index, tight_left, tight_right) is a classic approach to this type of problem and is taught in numerous public competitive programming resources, such as tutorials on CP-Algorithms, GeeksforGeeks, and various YouTube channels. I learned this technique from these common sources and applied the standard template to solve the problem. The core structure of my code is therefore very similar to anyone else using this standard algorithm. For Problem G: For this problem, my solution uses a prefix sum array to keep track of the balance of '0's and '1's, which is also a common technique. The final answer is derived from a mathematical formula based on the properties of these prefix sums. While this is more problem-specific, it is possible that my logical reasoning and mathematical derivation were similar to other contestants, which could lead to similar-looking code, especially in the calculation part. I want to sincerely assure you that I did not collaborate with any other user or copy any solution during the contest. The similarity arises from using well-known, standard algorithmic templates and common problem-solving techniques. This incident has been a serious lesson for me. I understand the importance of maintaining code originality and developing a unique coding style to avoid any suspicion of plagiarism. I will be much more careful in all future contests. I would be very grateful if you could review my case. I am willing to accept any penalty if my explanation is not sufficient, but I hope my account will not be blocked. Thank you for your time and understanding. Sincerely
I got same message twice in my first account. so i created this . I became pupil then my rating rolled back for 1029 and 1032 round.
Appeal for "My solution 324842333 for the problem 2121C significantly coincides with solutions of 1 Other", I was quite surprised and shocked seeing the mail, totally unexpected. I had submitted my code at 8:45 (IST) and then continued to code with my other problems and finishing the final one at about 10:07 (IST), All my solutions have a laid out consistent writing style, with significant inspiration from youtube tutorials and video lessons. I still can't figure out how my this other person, who submitted the problem about more than an hour later, got it same as mine, even though his solution looks like it's been directly off GPT. Please take a look at it and provide a solution. Thank you for your time and understanding.
324828250
Cool
0
so my rank in this contest increased from what it was before. This is probably because of the rollbacks. So when will the changed ratings come?Or will they not change?