Hello, Codeforces!

__baozii__ and I are glad to invite you to participate in Codeforces Round 1087 (Div. 2). The round will take place at Mar/21/2026 17:35 (Moscow time). There will be $$$6$$$ problems, and you will have $$$2$$$ hours to solve them. The round will be held according to the Codeforces rules and will be rated for division $$$2$$$.
At least one problem will be interactive, so we highly recommend you to read guide for interactive problems before the contest.
UPD: score distribution:$$$500 - 750 - 1500 - 1750 - 2250 - 3000$$$.
UPD:editorial
We would like to thank:
- Sugar_fan for coordination.
- Alexdat2000 for Russian translation.
- MikeMirzayanov and KAN for the best platform.
- Um_nik, Dominater069 for nutella testing.
- Tobo, Intellegent, A_G, k1r1t0, _istil, nifeshe for red testing.
- 0x3F, Proof_by_QED, FelixArg, DNR, -firefly-, Timosh, Arpa for orange testing.
- madlogic, Amao_Fox, Jamshed11 for purple testing.
- chromate00, simplelife, Argentum47, satyam343, SkyWave2022 for blue testing.
Wishing everyone good luck and high ratings!
upd:
top $$$10$$$:
top $$$10$$$ rated:
- bismispis
- undefined_Ryan
- Cody473
- qwertyuiojhygtfdfg
- AJ123496
- pixelcoder20
- Ravnik
- Khai2007
- ixumqwq
- _annhien_ruby22
Notes that there will be an update about the top $$$10$$$ after roll-back.








Auto comment: topic has been updated by OtterZ (previous revision, new revision, compare).
Auto comment: topic has been updated by OtterZ (previous revision, new revision, compare).
Spelling for division is wrong in the following statement, please correct :). The round will be held according to the Codeforces rules and will be rated for divition 2
as a tester, qp
Auto comment: topic has been updated by OtterZ (previous revision, new revision, compare).
Auto comment: topic has been updated by __baozii__ (previous revision, new revision, compare).
watch me win this contest
OK,I'll watch you on the top of the standings but still get grey because it may be your first trusted contest.
I did it! I solved all the problems in 5 minutes, and got 0th place(because of my good performance), but sadly, codeforces only display places starting from 1, so that's why I'm not on the top. But I hope mike will fix the bug, or at least the rating update for me, but if not, then I'll email mike to fix the bug.
woah there buddy, there is also me
watch me lose this contest
watch me lose and you win this
meanwhile, I'm gonna be teaching tourist and jiangly some real skills
OK,I'll watch you to 4000 starting from the contest.
sybau
Bhai thodi sharm kar le
(I don't understand why I'm getting so much hatred through downvoting)
what is this even? Learn english
no bullying
How was this blog written 3 weeks ago?
I think it was drafted 3 weeks ago, and undrafted now
Yes.
As a tester, note that at least one problem is interactive.
Let me guess, the interactive problem will be most likely on problem F or (with smaller probability) on problem E 👀
Ok I got downvoted so maybe my guess is wrong, we will see after contest who are correct one the downvoters or me? ;)
I predict D, and also, let it be so that for every problem, there is at least one predictor, then someone will be correct
I'm sure that the who got the correct prediction may have a good result.
I predict E will be interactive and F will be a modulo 998244353 problem
this turned out to be a problem С ;)
As a Candy man, hope I can get back to specialist
Alright, time to become specialist again! x)
You are not alone my guy :)
As a tester, I tested
500+ IQ
Hope to do well and reach specialist in this contest!!!!
As a linger, I usually sleep early.
make it easy also. :p
Hope to don't lose Expert, please...
here is the algorithm:
If you don't participate: You're 100% guaranteed to keep your expert title.
If you participate and keep expert: Congratulations! 🥳
If you participate and lose your expert: At least you are not alone because I will lose the expert title too :3
You forgot one brach:
Yeah you're right ✅ I forgot that edge case 😅 Losing expert title by going to CM is not on my thought 😂
Last time you said "Hope to don't lose specialist", you did lose. You became expert.
lessgo
Been forgetting to enter two contests in a row now... hope I can at least participate in this one.
Hope you can bro
finally i didnt forget about the contest and became green
Congrats!
As a yiren, I usually rush around in my wheelchair.
Auto comment: topic has been updated by OtterZ (previous revision, new revision, compare).
I hope my rating can reach 1300 in this competition, and I also wish everyone good results.
Good luck :D
Impossible! The rating change is kind of "zero sum" game, someone gain rating by "stealing" other that losing rating >,<
My 23th try to become master!
Good luck!
when can we see the score distribution?
Interactive Problems problem me a bit
Nice art btw, really good knowledge of Microsoft Paint there
well done
Auto comment: topic has been updated by OtterZ (previous revision, new revision, compare).
Hope for short but nice problem statements like the announcement!
Auto comment: topic has been updated by OtterZ (previous revision, new revision, compare).
Good luck to everyone in the contest! Hope you all perform well and gain a lot of rating!To be Legendary Master in one day!!!
I hope that after this competition I can become a Specialist. Come on, come on!
Hope to solve first 2 problems under 20 minutes.
Hope to get a purple today!
People who still participate to contests in AI era seems to me like real fighters (which include me)
oh no, F problem was solved by 0 LGM while many unrated or newbie accounts solved that, VERY VERY SUS!
I guess this shouldn't be posted during contest as other cheaters might figure that a problem is solvable by AI.
C was very good and tricky problem we have to think carefully
I tried querying (1, 2), (3, 4), ..., (2*n-1, 2*n), then doing either (1, 3) or (2, 4). I know that is wrong, but am I far off? It doesn't seem like (1, 2), (3, 4), ..., (2*n-1, 2*n) is the correct approach.
Its partially there.
You only have to solve n = 2 for any n
First query (5,6), (7,8) .....
if you don't find the consecutive 0 it means that half of the numbers in the range [5,2*n] are 0, and half of them are non-zero, which means that half of the numbers in [1,4] are 0, and half are non-zero(which is 2).
Now there are 6 ways for the first 4 numbers
0 0 x y
0 x 0 y
x 0 0 y
0 x y 0
x 0 y 0
x y 0 0
now after querying [5,2*n] interval (if we found an answer there, we will exit) We will be left with exactly 3 queries
We will do the following 3 queries 1 2 2 3 1 3
If we find an answer, then exit, and if not, then index 4 the answer. See the above 6 permutations and note that the order of x and y doesn't matter
and also try to prove that if we don't find an answer in [5,2*n] then there are exactly half of 0 in that interval
This makes perfect sense!
I hate Guessforces
Hello guys can someone tell me about verdicts once again. I am new to this. I tried A and all solutions passed when I run my code. But it says failed on pretest. Why?
The sample that is included in the problem is only the first test. Codeforces includes secret tests that your program has to solve and you don't know what they look like, of course they do obey the constraints in the statement. If your program fails any of these tests in any way (wrong output, crashed, took too much time/memory, etc...) you don't solve the problem. You basically have to write a program that solves any input correctly.
So basically pretest 1 is 10 input of the question. Rest all pretests are hidden and there was a problem there right?
Proud to announce that randoming 300/600 lesfs as $$$r$$$ in F and then solving for each one in $$$O(n)$$$ doesn't pass tests by WA/TL
Which is a good thing for contest authors but bad thing for me :).
C was a very cool question! Also thought D was easier
Problem C is so goated , problem D is tuff implementation problem .
Genuinely what was so "goated" about it?
It was just, solve for $$$n = 2$$$ case, extend to all $$$n$$$. And solving for 4 indices with 3 queries was just guess/brute force.
Problem statement for $$$B$$$ was the worst
understanding it was the challenge imo
A pen and paper always helps in these type of questions, you just need to assume a value for index i and do the same for j, in no time you will realize the that you just need a k which is more far from i than it is from j. And after that you just need to count the elements which were smaller than i and bigger than i, and output the maximum of them.
I spent way too much time on B :( Solved it at basically the end of the contest
I had difficulty understanding B. When you say all possible integer values of k this means -10^9 <= k <= 10^9 and for all these values the given equation should hold. The problem is — lets just say k = ai then |ai — k| becomes 0 and in this case |aj — k| basically becomes |aj — ai| will always be either 0 or or positive and equation doesn't hold true so for every index it becomes 0. Do they mean that for any k if the equations holds true then we can count it? I found this statement really confusing :(
No, "all possible values of k" means that you choose a value k which maximizes the count of such indices j which hold true for the given equation. Also there were no constraints for k, like you can theoretically choose any value of k. You just need to maximize the count of j which hold true for the given equation with that particular value of k.
Yeah exactly me too. Since there must be a solution, we have to change our understanding of the problem. The inequality should hold only for some choice of integer k. There are infinitely many integers of k which will maximize the number. But yeah, I do not think that the wording is clear.
the moment you realize you only need to solve
n=2for problem C .. aaahhh !! I was too slowalso spent much time understand what B was saying ... reading time >>>> coding time lol
The n <= 5000 in problem B was crazy hhhh .
yeah I was about to use something like segment tree or pbds but then saw this.... also I realized B doesn't use such Data structures
same bro hhhhh , I start thinking about fenwick tree LOL
I don't really like B because it can be solved using brute forces. And C is fantastic. I really want to have more problems like this in the future.
The contest, sadly, is not a cheater-free one though...
C is a cool problem
This time the problem texts were long but clear. I solved 2.
Feels nice I will become
Specialistfor the5thtime, and C was really nice.While you wait for the official editorial, checkout the hints for all the problems on CF Step.
gave contest after ages! got 1 min late on E, i am so angry!!!
https://mirror.codeforces.com/contest/2209/submission/367735094
Can you check why my solution fails?
Take a look at Ticket 17529 from CF Stress for a counter example.
Auto comment: topic has been updated by OtterZ (previous revision, new revision, compare).
Only solved A and B
Does D have a non brute force solution?
Got cooked again.
Btw Nice Problems C and D.
First Interactive problem solved.
Indeed a good feeling
Maybe it's better to let A be between C and D:)
it's not easy to debug:(
I don't think so.Of course,A is easier than C.
How to optimize O(qnlogn) solution to O(nq) in problem E???? I have found a qnlogn solution but couldn't optimize it further.
It's very sad that I can't crack my solution problem C...
For question C: I rushed it last minute so I just assumed the oracle always returns 0. but that aside, the response of the oracle in the test cases isn't making sense to me QwQ
if that's the case then the second query (3, 1) should have returned 1 (rather than 0)? Or am i tripping?
idea is after checking the first n — 1 (disjoint) pairs, we now know there's at least n — 1 non-zero in first 2n — 2 indecies. So the last 2 has to contain at least 1 zero, and we have 2 queries left. We check index 2n — 1 against the first 2 numbers(that was queried in a pair), if they both return 0 from the oracle, then either both of the first 2 numbers are non-zero (there are n non-zeros in the first 2n — 2)or the the number in index 2n — 1 is non-zero. in both cases the 2n th number must be 0
Problem C is excellent, but unfortunately I realized I could query in pairs and didn't consider how to use the last two query opportunities.
Excuse me, for problem C, my solution passed the tests, but I noticed that if the hidden array were [1,0,0,2], it might cause an issue. Since this problem doesn’t support hacking, I was wondering—does this situation never actually occur, or is it just a problem on my end?
Test Cases On C seems to be weak.
A code which is wrong on very basic Test case, is accepted.
Submission — 367632597
Test case -
1
2
1 0 0 2
Answer should be either 2,3 but the code gives 1 :(
interactive tasks <<
Yess, we should double them :P
problem b was much easier than problem a in terms of understanding
also , in c , i am wondering 1,0,0,2 can be one edge case that would give WA
if anyone could solve D , would love to understand its approach
Could Anyone explain why my submisson is skipped, i didn't do anything wrong and against the rules
367638369
System test would like to skip to the last pertests passed solution.
Hello
I have a request regarding the clarity of question statement in B.Array problem of this contest round 1087 . Basically the question says -
"For each index i , find the maximum number of indices j such that j>i and |ai−k|>|aj−k| , over all possible integer values of k"
this conveys the wrong idea compared to what is acutally happening in the testcases, and misguides the reader, as it clearly implies that we have to consider all possible k values instead of any one, which is actually confusing.
I sincerely request for less misguiding problem statements.I am not saying that the question should be direct, but not misguiding like in this case.
I think the statement is actually correct. ‘Over all possible values of k’ means we can choose a single k that maximizes the count for each i, not that the condition has to hold for all k simultaneously. It’s a standard optimization phrasing in CF problems, so the behavior in test cases is consistent with that interpretation.
It changed from over all possible integer values of k to over any possible integer values of k
2209C - Find the Zero The testcases for Problem C seem weak. The solution provided below passes all official tests, but it fails on certain valid edge cases. for example(n=3): [1, 0, 0, 2, 3, 0]
My code works fine,.. I actually finished it after the contest ended and verified it during a virtual contest run, and it passes all cases there, including edge scenarios
Your approach works for most cases, but it misses properly resolving the last 4 indices. After the initial pairwise checks, there can still be multiple valid candidates left, and using just a single query like query(1, 3) isn’t enough to uniquely determine the answer in all edge cases (like the one you mentioned).
In my solution, I handle this by explicitly comparing the last 4 elements using multiple queries ((a,b), (a,c), (b,c)), which removes ambiguity and guarantees the correct index in every configuration.
I would like to clarify that the solution I shared isn’t mine. I found this submission while browsing, and it got accepted even though it seems to give wrong answers on some cases.
Yup I think the test cases are weak, I submitted a similar solution which passed the pretest and is currently accepted, The following testcase would fail
1 0 0 2
delete
problem $$$D$$$ is very similar to 1954D - Colored Balls
Auto comment: topic has been updated by OtterZ (previous revision, new revision, compare).
good contest!
just ban all those <1600 rating that solved F, they are all cheater or smurf participants
Oh god, only the headquaters know if we should do that.
you know, there are many people who is strong but don't use codeforces
99% smurfs or cheaters bro, ban all of them is the better solution
Why is it top 10 rated and not top 10 trusted? Doesn't that encourage unsportsmanlike conduct?
We can not be sure if they are not cheating or others are cheating, we are just checking the submissions.
Yo what up with these top 10 lol
watch me win this contest
I got the answer wrong in Question B because I made the array size too small. I'm so sad.
Hello, I would like to clarify that I did not copy or share my solution for problem 2209B. I solved the problem independently during the contest. My approach was based on a straightforward implementation of the idea required by the problem. I analyzed the constraints and derived the solution step by step on my own. I believe this approach is quite natural for this problem, which may be why my solution appears similar to others. I did not access any external sources or other participants' code during the contest. Any similarity is purely coincidental. If needed, I am willing to explain my approach in more detail or provide further clarification. Thank you for your understanding.
OK, contact mike with the proof
I have read the notice and acknowledge it. I will ensure greater care in future contests.
Hello,
I received a plagiarism warning for this contest. I want to admit that I shared my code during the contest, as I was not aware that it violates the rules.
This was my mistake, and I understand it now. I will make sure not to repeat this in the future and will follow all contest rules strictly.
I apologize for this.
Respected Codeforces Team,
I sincerely apologize for violating the rules during the contest. I understand that copying code is against the principles of fair competition, and I take full responsibility for my mistake.
This was my fault, and I assure you that it will not happen again in the future. I will make sure to solve problems on my own and follow all the rules properly.
Thank you for your understanding.
Hello everyone, @OtterZ,
I’m new to Codeforces and competitive programming, so I’m a bit confused about what happened. I was already rated in this contest, but today my rating suddenly decreased and all my submissions are marked as "skipped". Because of this, my rank went back to Pupil.
If I violated any rules, I would really appreciate it if someone could please tell me what rule I may have violated so I can understand and avoid making the same mistake again.
Thank you for your time and any response is greatly appreciated. Peace.
Usually there'll be a message from system.
I checked, but the notification isn’t showing anymore. Can I still appeal the issue and get my rating and skipped contest restored?
This is new to me, and it’s really disappointing that my rating was taken away. I worked hard to solve the problems, and this was only my fourth time participating in a Codeforces contest. I hope this can be reviewed. Thank you.
Auto comment: topic has been updated by OtterZ (previous revision, new revision, compare).
My Codeforces handle is mayankbansal818. I am writing regarding the disabling of my account after Codeforces Round 1087 (Div. 2).
I want to sincerely apologize for my actions. I understand that my solution for problem 2209D violated the contest rules due to similarity with others.
I want to be completely honest. I have participated in many contests on Codeforces and have always tried to solve problems on my own without cheating. However, in this contest, I made a mistake. For the first time, I referred to AI assistance during the contest because I was worried about maintaining my rating. I realize now that this was completely wrong and against the rules.
I deeply regret this decision. It does not reflect how I usually approach competitive programming. I have learned a serious lesson from this, and I assure you that I will never repeat this behavior in any contest again.
Codeforces has played a very important role in my learning and growth, and losing my account is very disheartening for me. I humbly request you to please consider my case and give me one last chance.
I am ready to accept any warning or penalty, and I promise to strictly follow all rules going forward.
Thank you for your time and understanding.
Sincerely, Mayank Bansal Handle: mayankbansal818