你好,Codeforces!
We (WDOI team) are delighted to invite you to participate in Codeforces Round 1098 (Div. 2), which will be held on May/16/2026 17:35 (Moscow time). You will be given $$$6$$$ problems, including two problems each having easy and hard versions, and $$$2$$$ hours and $$$15$$$ minutes to solve them. This round will be rated for the participants with rating lower than 2100.
The problems are authored and prepared by Sugar_fan and me.
The score distribution:
| A | B | C | D | E | F |
|---|---|---|---|---|---|
| $$$500$$$ | $$$750$$$ | $$$(1500+1000)$$$ | $$$2500$$$ | ($$$2000$$$ + $$$1500$$$) | $$$3500$$$ |
We would like to express our sincere thanks to the following individuals for their contributions and for making this round possible:
Sugar_fan for his incredibly dedicated coordination and support,and he has also deleted some problems and modified some to make the round better.
Um_nik for preliminary review of the round and giving me courage.
Alexdat2000 for Russian translations.
Otomachi_Una, juan_123, CirnoNine, fanhuaxingyu for their valuable contribution to the problems.
EnofTaiPeople, _istil, Welcome24ever, Mitsukasa_Ayase, SATSKY_2025target_LGM, Serval, __baozii__, juan_123, Zheng_iii, Arpa, CirnoNine, Anoth3r, hushuqi_qwq, fanhuaxingyu, SunJude, ddndd, RioBlus, bluket, bzy, CSP_Sept, YoungLau, ihy, 2021cjx, alij_8, gouhhmumu for testing the round.
MikeMirzayanov and KAN for the amazing platforms.
And finally, You for participating.

We are a team made up of fans of both competitive programming and the Touhou Project. Although this isn’t our first time hosting contests on Codeforces — we previously organized Codeforces Round 796 (Div. 1) and Codeforces Round 796 (Div. 2) — I authored most of the problems in this round with little assistance. In 2022, most of our members were Olympiad in Informatics (OI) participants, but over the four years since then, many have stepped away from OI and competitive programming. While the older generation may eventually fade away, newcomers like me aim to keep our community alive by injecting fresh energy and passion into what we love. I hope this kind of pure love persists and carries on.
Across these six problems, you will meet characters with their own distinct personalities and beliefs.
Marisa stole Reimu’s takeout and vanished before the shrine maiden could react. Hungry and sharp-eyed, Reimu marched to the Scarlet Devil Mansion, challenged Remilia to a fierce game of Hisoutensoku, and claimed victory—along with her lunch. Near the Misty Lake, Cirno found a cold number frozen in the ice. With a child’s certainty, she reshaped it into a beautiful ice crystal, perfect and gleaming. Atop the Youkai Mountain, Sanae watched the stars and prayed for fortune, her quiet hopes rising with each passing light. Elsewhere, an Amanojaku teetered on the edge of ruin. In Yukari’s contest, it solved a problem others deemed impossible, reversing its fate and reclaiming its place.
Hearing of these scattered lives, Momoyo built a grand network across Gensokyo — linking shrines, mansions, and factions. Conflict gave way to conversation, and peace settled softly over the land. Harmony replaced trouble, and laughter returned to the air.
Help them overcome these trials through your logic, and find satisfaction in lending a hand. We hope you enjoy the round. Good Luck and Have Fun!
May Gensokyo’s peace endure — and may the real world, too, know such days.
UPD1: Tutorial
UPD2:
The top five (official):
The top five (unofficial):
The first solvers :
UPD3: Apology









Same task arrangement as the last full-cf div2 round!
I like that and hope to become master again awa.
Good luck to everyone!
i am gay 676776767766
hakita from ultrakill also if you are reading this read infinite jest
Is there solutions of this contest ?
As TheWorse, I will become the worst of this round. And future rounds.
worse part 2?
As a fan of yiren, I will be in my wheelchair in this round.
Are you Kuro_Neko?
No, just also a fan(*╹▽╹*)
As a tester, I enjoy watching you suffer.
As a tester,wish you good luck and enjoy the contest! Kochiya Sanae is so cute!!!
Yes !!!
As a tester, I hope you can possess the same wisdom as Cirno to solve these problems.
Sometimes I feel like changing my profile picture to anime girl is my missing piece to improve.
Its the secret meta
As a tester, I am a tester!
Manifesting postive delta for all.
As a participant, trust the Chinese
China stays committed to peace, working with the world for stability and development.
I hope your next profile picture is ready.
Thank you, I'll be expert in less than 3 months In Sha Allah
My Specialist profile picture is ready after this performance hahahaha
ok bro, all the best
As a tester,I tested.
I'm a member
is this genshin impact?
no its touhou project
While the older generation may eventually fade away, newcomers like me aim to keep our community alive by injecting fresh energy and passion into what we love. I hope this kind of pure love persists and carries on.
why does she hold a shovel? what does it have to do with wind
As a potential participant, I potentially participate.
As the statement writer for the last WdOI round, I look forward to reading new fancy Gensokyo lore.
I'm sure you'll like it. QAQ
Why no interactive problems? I love interactive problems!
As a participant, I will observe other people solving F.
.
May you succeed.
fyi, MBBN is a cheater who builds credibility by generating (sometimes sloppish) AI comments. They think it will cover up their cheating.
Sadly, MBBN isn't the only one who posts AI comments with this purpose.
Wow...
i'm very intersted
Can you bring it to Luogu?
I'm interested.
Seriously?
yes
Hi Jeffrey, welcome! As a Chinese CP player, I'd recommend you try to register for QQ instead of WeChat, as 99% of our ICPC/OI discussions and CF/AtCoder groups are on QQ. Also, you MUST check out Luogu (luogu.com.cn), the largest CN CP community.Hope this helps!
good luck to everyone. peace <3
Hope I can solve at least one problem to get some rating... and to enable myself to write blogs (and catch cheaters).
☺
khushnid_91 I'm a member. translate into Russian.
Can someone explain what does 1500+1000 means in question c.
C will have Easy & Hard Version
Is that AI-generated art? Ugh
As a newbie, solving B would already make my day lol
As a participant, let's go
Why so loooooooooooong queueueueueueueue :-(
as a tester and a student suffering from midterm exams, wish everyone good luck!
aaaahhhh !!! ... queue too slow
Queueforces during the contest again... and again...
kiram to kos nane jendat madar kosde ye pedar kiri
koskesh kiri in che anie khar kosde
soalaro az to konet dar ovordi ?
I am stuck, I am in WAforces
я не расист, но нормальных раундов от китайцев я пока не видел
C is too hard for me. I have tried 10 times. But all the result is wa 2
Why was D 2500 points?????
The problems stay in the queue for a very long time, and that affected my performance badly from the very beginning of the contest.
Besides that, Problem B was basically just printing the answer — there was no real work involved. Most people probably got wrong answers because of some corner case. Honestly, I don’t see much value in a problem like that.
Bad starts have a huge impact on performance throughout the entire contest.
I think there was no work involved for you but many people like me it was a learning. I was unable to solve it. Its discouraging to see your comment. I dont think the author's are stupid enough to give a print answer question. You got to get the answer to print answer and many people struggled on problem 2 until it clicked for them.
First of all, I don’t care about your struggle. Secondly, you already submitted the correct solution in 11 minutes, but if you had changed the condition to: n <= 3
you would’ve gotten Accepted. So your mistake was because of a corner case too.
yeah my bad. Thanks. I dont want you to care
not sure if it was intended, but example test cases were very useless
I agree.
CornerCaseForces :(
meow:)
I felt it was kind of an easy round?
$$$A$$$ and $$$B$$$ were pretty easy. $$$D$$$ was kinda a common idea.
$$$C1$$$ and $$$C2$$$ genuinely gave me a headache, but the idea was simple though.
Some feedback:
How would you do 3d Mo's here? you can do it with a segment tree which holds 8 values per node and it works, but the implementation is hell on earth
Honestly, getting past B, C1, C2 was so fckn difficult. I'm still not sure I'll pass tests on them. Tight constraints on D as well.
Loved the contest! TL too tight on D tho
I was really astonished when I see problem C appears in Codeforces. The style is so special in Codeforces...
Maybe after this round, I can participate in Div.4 rated (laugh)
Ragebait contest
so hard B :/
Bro mistakenly set the questionnaire of Div 1. :(((
Hardforcess
implementation hell...
Waiting for editorial..
Hello! I have a question regarding B. Suppose you have the 2 placed such that on both sides the number of free position is equal ? Is the answer then not k + min(dist,n-dist) — 1 ? The -1 comes from: She stays, he moves towards her, then she starts moving the other way, so in the k he gains 1 distance to her, hence it should be less. Let me know !
same doubt,,i did that got a wrong sub,, changed it to the basic case and it passed
case n = 2 and n = 3
yep when d==1 && n<=3
yeah that an edge case ,, but other than that shldnt k + min(dist,n-dist) — 1 be correct in terms of equal distribution
In the case that there are only 2 or 3 positions in the circle, the answer is always 1 since every node is adjacent to every other node.
I forgot about this ;(((
If she stays still, she doesn't spend any moves, she still has k moves left.
Ohh, this might be it. I didn't realize this and yes that's why it works. Thanks a lot!
if in the first second, he moves towards her. Then for next k second it will continue to maintain the same distance. (He comes close, she goes away). after moves ends, now he will have to cover dist — 1 more. if k <= 3: then it will end in the first second
For example x1 at position 2 and x2 at position 5, with n = 6 and k = 2. I would say the answer is 4. She stays, he moves to 3 in 1s , then she moves to 6, him to 4 in 1s, then he goes to 6 in 2s. Total is 4 which is 1 less than k + min(3,3).
k is the number of total moves. If she stays (doesn't move) it is not counted a move
whoever made c
never cook again, impl hell isn't fun please remember that
C1 TLEforces
weaksampleforces
Any hints for E1?
I rarely give contests But when I give contest it be like :
I don’t know what the point D has 2e6 input, I know author want to hack O(n lg n) solution, but making n 2e6 only make the bottleneck be input, and force users to use fast read, which is meaningless. Author can make alternative way, like given a random generator and let user generate the points by themselves.
Why do I even have to rewrite my C++ solution into pure C just to pass Problem D’s time limit?
corner case contest :/
Please make the TL for problem D bigger and rejudge the submissions. The TL is too tight, to the point where the bottleneck seems to be input processing. Implemented it in O(N) but still got TLE.
I had a stupid bug in C2 because I didn't pay attention that n could be equal to 1. I didn't manage to find it till the end of the contest. Sadge.
C was a nightmare
My initial rating was 2098. I originally hoped to reach Master after this contest.
But, I got stuck by numerous corner cases on problems C1 and C2, resulting in six consecutive WA on pretest #2. This directly led to my poor performance, and I feel really upset about it.
In addition, I think setting the upper limit of n in problem D to 2e5 would be the most appropriate. Making n ≤ 2e6 only forces us to add a bucket sort on the standard solution, and I really don't understand why the problem setter chose to set n up to 2e6.
I've not used bucket sort, looks like I'll get cooked in system testing
corner case forces :|
I lose the score badly because I don't know "llabs()" at C1 and C2…
Because of many details, I submit wrong answer eight times. These scary details make the round terrible.
You say you want to carry on the "pure love" of that passion.
But which I see is you are just stealing others love of CP by setting such ragebait problemset.
TIME LIMIT EXCEEDED ON TEST CASE 19-forces
goodbye expert
i could not even say a hi sad
This is by far the worst Codeforces round i participated in. 0% problemsolving 100% debugging. Both B, and C just consisted of considering the edge cases correct.
.
CornercaseForces
.
Maybe because of specially odd Problem C, TLEForces of Problem D(I didn't finish that, I just heard from others) and queueueueueue-forces at the beginning at least 30 minutes of the contest...
It will soon become negative(
Worst contest I have ever participated in, by far. So bad, it compelled me to make my first comment. Really upsetting.
The purpose of setting problems is to torture the contestants.
Unpopular opinion but ppl complaining about debugging, corner-cases and hard implementation should probably work on those things rather than blaming the author
Cornercaseforces
Positive thinking, C1 and C2 are good practice for debugging. Test cases are easy to generate and naive solution is quite straight forward to implement.
long queue,corner case,the cn round is too bad,I only solve 1 problem,it makes my rating -150
Two question.
Why C appears in Codeforces?
And why n in D approach $$$2 \times 10^6$$$?
Sorry.
Could you explain the trouble in C?
There're many corner cases while example isn't intensive enough.
However, the problem is right and it's can be implemented easily.
For me, I didn't like that the difficulty came from implementation and considering casework rather than an insight or observation (I'm doing codeforces for the latter!). C1 was completly unnesary because you either code a braindead bruteforce which doesn't belong on this site or solve C2 anyways. You could also have reduced many people's frustrations by adding a requirement like "your answer must have the same number of digits as a", focuses the problem on the idea of matching prefixes and less on casework.
why C>>D
Holy Reference
insane amount of cheaters in the top 100s
Please don't worry about the positive comments.
A bad round!!!!!!!!!
Time limit exceeded on pretest 19 and Wrong answer on pretest 2-forces
why C>>>>>>>D :(
Can anyone spot the bug in this code(or any counter-example)?
Code
Can someone help me out i am stuck in problem C1.
My code in C++
I also improved but still wa in test 2My code in c++
cnm
Proud to be the first solver of problem A. Enjoyed the problemset, hope to see more from the WDOI team!
For the problem B the Pretest 2 test number 10 The test is
4 1 3 1 and the answer should be 2 and not 3 as we can't increase the distance if min_dist is equal to n/2. Please tell me if I am wrong
Remilia can stay and wait for Reimu's moves, So for every case that $$$n≥4$$$, distance is unchanged after k seconds. For case of 4 1 3 1:
got it
?!strongstrong?!
A,D 800,B 3500
Asia round!!!
Hello moderators, I would like to clarify regarding the plagiarism warning on my submission 374806988 for problem 2228E1.
I did not intentionally copy code from any participant during the contest. I solved the problem on my own and submitted my own implementation. If there are similarities with other submissions, they were unintentional and possibly due to common logic or implementation patterns for the problem.
I respect the contest rules and understand the seriousness of plagiarism concerns. I will also make sure to write more personalized implementations in future contests to avoid such situations. Thank you.
Subject: False Plagiarism Appeal — Round 1098 (Div. 2) — Handle: sudeepreddy7893
Dear Contest Coordinator,
My handle is sudeepreddy7893. My submissions for Codeforces Round 1098 (Div. 2) were skipped due to a plagiarism flag on problem 2228E1, matching with user MBBN. I would like to request a manual review of my case because I submitted my solution significantly earlier than the other user, proving that I did not copy from them.
Submission Details & Timestamps: My Submission ID: 374810486My Submission Time: 2026-05-16 18:41:31
MBBN's Submission ID: 374843969MBBN's Submission Time: 2026-05-16 19:30:02
As shown by the system records, my solution was written and officially submitted 48 minutes and 31 seconds before user MBBN made their submission. I did not collaborate with this user, nor did I share my code. Any structural similarity is either a consequence of the standard mathematical approach to this problem or a result of my code being accessed after my submission without my knowledge.
Explanation of my logic:To solve the queries efficiently, I first isolated the fixed sum and counted the number of open slots (free) containing -1. I used the standard stars-and-bars combinatorial formula C(R + free — 1, free — 1) to find the total valid configurations for the remaining sum R.
For the contribution of the prefixes, I applied the linearity of expectation. Since each empty slot expects an equal share of the remaining sum (R / free), the expected sum of a prefix containing A empty slots is simply ex = A * R / free. To compute the expected squared sum, I expanded the algebraic identity (fixedPref + freePref_sum)^2 into fixedPref^2 + 2 * fixedPref * E[freePref_sum] + E[freePref_sum^2], which I calculated using the combinatorics coefficients accumulated in the ex2 variable.
Given that the timeline clearly shows my submission came first, I kindly request that you restore my rating for this round. Thank you for your time and for maintaining the integrity of the platform.Best regards,sudeepreddy7893
As a Chinese, I will give this an upvote
(Sorry to my poor English and my beginner code at first) Subject: Potential error in Editorial for Problem 2228B The 2228B's answer have some problem.When the distance of x1 and x2 == n / 2,the x2 should choose stay in place,and the x1 should stay too until the finally second,the k seconds x1 can choose move to make the distance -=1.Such as the test of n = 4,x1 = 1,x2 = 3,k = 2,if x2 move,the distance become smaller,it's wrong,so x2 should stay in place,and x1 didn't move in 1th second.But in 2th second,x2 also stay,x1 should move to 2 or 4,so the answer should be k — 1 + distance at first that is 2.But in the editorial,the answer is 3. I put my code here,it maybe have some wrongs: ~~~~~
include
include
include
using namespace std;
int dis(int n,int x,int y){ int dis = min(abs(x — y),abs(x + n — y)); dis = min(dis,abs(x — n — y)); return dis; }
signed main(void){ int LOOP; cin >> LOOP; while(LOOP --){ int n,x,y,k; cin >> n >> x >> y >> k; if(n <= 3){ cout << '1' << '\n'; continue; } if((dis(n,x,y) == n / 2) && k > 0){ k -= 1; } cout << k + dis(n,x,y) << '\n'; } return 0; } ~~~~~ Thanks!
Oh,sorry,my code had some problem in this comments