Καλησπέρα/안녕/สวัสดี/أهلا/你好 Codeforces!
With great felicity, immense joviality, and unparalleled positivity, we, a team of authors united by our creativity, originality, ingenuity, and curiosity, consisting of omsincoconut, chromate00, ttamx, yse, Marszpace, an individual of mysterious identity, and me, SpyrosAliv, have the distinct opportunity and absolute pleasure to invite you to WorldQuant Round 1 (Codeforces Round 1128, Div. 1 + Div. 2), an event of exceptional quality and remarkable diversity, which will become a reality on Oct/17/2026 17:35 (Moscow time).
You will be presented with 8 problems of varying complexity, difficulty, and subtlety, with exactly 3 hours of availability to demonstrate your ability, capability, adaptability, versatility, productivity, efficiency, accuracy, agility, rationality, and problem-solving proficiency. Some problems may feature a multiplicity of subtasks, providing additional flexibility and accessibility while preserving the overall integrity of the contest.
Of course, with absolute certainty and without any ambiguity, at least one problem will be a communication problem, introducing an additional layer of interactivity, connectivity, and unpredictability. Therefore, to maximize your probability of success and minimize the possibility of unnecessary challenges, we emphasize the necessity and priority of reading the guide for communication problems before the contest.
Special thanks to the following people for helping make this round a reality:
- flamestorm, simplelife, ItzsleepyXD for proposing problems that are not ultimately used in the round.
- Um_nik for pre-reviewing the problemset;
- Proof_by_QED for being the best coordinator of all time;
- The testers: EvenImage, nifeshe, A_G, __baozii__, Error_Yuan, turska, Stathis, Mentholzzz, cry, Timosh, coder3000, ReverseFlash081, Argentum47, Hori, wakanda-forever, Lxnsr._th, coder3000, cowthecow, Borhom, blackslex,samsoom, nik_exists, Nasa, Mysticmage45, SkyMagic, Teto, coder3000.
- Alexdat2000 for translating statements to Russian;
- MikeMirzayanov and KAN for Polygon and Codeforces platforms.
- and last but not least, You for participating!
Score distribution:
Congratulations to the winners!
Editorial
And now, a few words from the sponsor!

Hello, Codeforces community!
We are happy to welcome you to the WorldQuant Round 1 and proud to support a platform where so many talented programmers learn and compete.
WorldQuant is a global quantitative asset management firm. Founded in 2007, WorldQuant develops and deploys systematic financial strategies across a broad range of asset classes and global markets. Our teams work collaboratively to drive the production of high-quality predictive signals (alphas) and financial strategies — the foundation of a balanced, global investment platform.
At WorldQuant Armenia, talented people with diverse backgrounds, including participants and prize winners of competitions like IMC, IMO, ICPC, and IPhO, work together to tackle challenging problems. We value curiosity, teamwork, and the passion to learn, creating an environment where people can grow, share ideas, and achieve great things together.
We are looking for talented individuals to join our team at WorldQuant Armenia in the following roles:
Please note that relocation to Armenia is required, and WorldQuant can provide assistance with relocation for successful candidates.
To apply, fill in the application form.
The winners will receive our exclusive branded swag:
- Hoodies + T-shirts for the top 5
- T-shirts for participants ranked 6–30
Whether you are competing for the top places or simply challenging yourself to improve, we hope you have a great time!
PS We reserve the right to apply strict compliance checks when finalizing the results in order to prevent unfair participation and rule violations.
Please note that prize delivery to certain countries, states, provinces, or territories may be subject to applicable sanctions, trade restrictions, or other legal requirements. We will make every reasonable effort to deliver prizes to all eligible winners, subject to any restrictions that may apply.








Hi Verity!
This blog teaches me more vocabulary than my English lessons. (Guys this is a joke only, no offense to my english teacher)
I thought you skip all English lessons to learn cp instead
shhhh don't say it out loud like that
Gonna master both speed and accuracy for this problemset… 8 problems, actually 10 if we count the easy versions, in 3 hours
Bro thinks we're all Grandmasters :skull Best of luck guy's :)
hey its me its verity!!!
ask me anything
i know about a million things
I'll do everything
i've got a question!
What's the capital of France?
Oui Oui Oui Oui, it is Paris
Merci!
why's the door locked up to tight?
Our brains are shrinking?
Oh tee hee hee, no need to leave
уи уи уи на$$$ иди
cant believe Waguri-san claiming to be Verity!!!
bro dont know the lyrics
would be to nice if you tell me...
Something is coming in 7 days!
Hello,I'm verity!
As an author, I have authored with authority.
is that a new type of verity?
Indeed
Indeed... I have slept long enough.
The kingdom of Heaven has long since forgotten my name, and I am EAGER to make them remember...
However, the blood of Minos stains your hands, and I must admit,
I'm curious about your skills, Weapon...
And so, before I tear down the cities, and crush the armies of Heaven...
you, shall do as an appetizer.
Come forth, child of man...
and DIE.
- Sisyphus Prime
Arthur Morgan
i can easily say you are from Thailand with this pfp))
Why though?
As a tester, I gotta say this might be my favourite div I tested till date. Wonderful job done by the authors ❤️
The score distribution is insane:)
As a tester, I tested twice?
three times*
As a tester, the problems are ver(it)y cool😀
Verity when Half-Life 3?
wtf is verity :cry:
minecraft mod
What will happen if I download this Minecraft mod on my laptop (my laptop really weak and have a lot of viruses) and ask Verity when Half-life 3?
he belongs to backrooms
Hey, it's me, WorldQuantity
Trade me anything
I know about a million strategies
Good luck to everyone participating in this contest! I wish you all the best!
ask gpt anything!
As a tester, It was my first time testing a round and it was really enjoyable :)
Hello! I'm relatively new to Codeforces, and I'm a bit confused by terms like Div. 1 and Div. 2. I don't see any division listed on my profile. How can I find out which division I'm in? Is there an easy way to check it, or do I have to calculate it based on my current rating every time?
Also, if my current division is, say, Div. 3, does that mean this particular contest isn't intended for me? If so, why am I receiving emails about it? Is there a way to configure email notifications so I only receive announcements about contests intended for my division?
This round will be rated for everyone :)
Div. 4 is rated for people with a rating below 1400
Div. 3 is rated for people with a rating below 1600
Div. 2s that are tied to a Div. 1 are rated for people with a rating below 1900
Standalone Div. 2 is rated for people with a rating below 2100
Div. 1 is rated for people with a rating of 1900 or above
Div. 1 + 2 is rated for everyone
thanks
Thanks a lot. Another question. Do you know if contest emails have some filter, I mean, does the system send news about all contests, or it checks if participant might be able to solve some problems there first?
Round announcement emails send information about every round, no matter what division is the most suitable for you to compete in. Plus, they can't judge the ability to solve a problem for every individual, so they don't send rounds for some specific divisions only. However, if they know you've already read a round's announcement at least a few hours before the round's starting time, they won't send emails about that round I think.
Hi! There is no filter based on whether you might be able to solve the problems. Contest announcements are filtered only by the division's rating limit. Div. 3 announcements go to users rated below 1600 and to unrated users, and Div. 2 announcements go to users rated below 2100. Rounds open to everyone, such as Div. 1 + Div. 2 and Educational rounds, go to all subscribed users. Your account qualifies for all of them, and your "Contest email notification" setting is on (it's on by default).
We checked our mail server (Postfix) logs for your address. There are eight deliveries: September 21, 24 and 25, and October 6, 9, 11, 13 and 15. That is every contest announcement sent since September 20, including Codeforces Round 1125 (Div. 3) and WorldQuant Round 1. Every one of them is logged as status=sent (250 2.0.0 OK) from gmail-smtp-in.l.google.com, so Google's mail server accepted them all. Nothing for you is waiting in our queue now. Logs older than about September 20 have already been rotated, so we can't check the August announcements. Our mailing system keeps per-recipient records only for the two latest campaigns, so for older ones the server logs are the only source.
Gmail accepting a message doesn't guarantee it reached your Inbox. Most likely the announcements are in your Promotions or Spam folder. If you find one there, mark it as "Not spam" or move it to Primary so future ones arrive normally. Some other providers, such as Microsoft and Apple, are currently rejecting part of our mail because of a blocklist issue, but that doesn't affect Gmail: it accepted all of your messages.
What is the solution to C?
Oui oui oui, it is DP
merci
No, It was simple just consisting of some if else block. Rather I believe B was bit tough than C.
You can solve it with DP if you define $$$dp_{i,j}$$$ to be if Moggity can win with $$$i$$$ evens and $$$j$$$ odds, bound $$$i$$$ to be a maximum of 2 since any extra evens are redundant, transitions are basically just checking if you can move to a losing state after an operation, use "prefix sums" (basically just a single variable) to avoid it being $$$O(n^2)$$$
Ahh!! Either way its solvable
Communication problems making a comeback before I do academically :(
I've learnt about verity just yesterday and it's already on cf, that's crazy
as a tester, can confirm that verity is skibidi
I bet a lot of people would ask Verity to solve the problems!
is it verity verity verity?, noo you only got 2 correct its falsity falsity falsity
Verity in an announcement makes me feel that this round will be interesting. Thanks to SpyrosAliv for adding Verity!
What is IMC?
since F2 is 5000, why isn't F placed last
verity :0
VERITY? :)
After participating this contest,
My ability, capability, adaptability, versatility, productivity, efficiency, accuracy, agility, rationality, and problem-solving proficiency:
Thanks in advance dear authors :)
guys i am a beginer, bully me
Hi Verity
first in my bloodline to witness verity on cf
yes! verity
verity
I know all the words here but never have thought of using them all at once and like this!
Boss, I swear, verity thing will work ah announcement
what's verity....
mem from minecraft
ahh..... i dont play minecraft ヽ(≧□≦)ノ
thanks for last round and for... verity?
Hopefully, after this round I’ll finally reach Legendary Grandmaster just like Kinder.
Not even CLOSE
I believe in him he'll do so bad his rating underflows
He'll do so bad his rating will go to 0 after underflowing anyways
This blog teaches me English more than "Story of An Hour" did. Maybe you guys can write literature on CF. Who knows whether the problems you created for today's round are your novels ?
https://www.youtube.com/watch?v=wcudhZorXmo
masterpiece
I hope I'll hit Specialist in today's contest
congozz
Thank you bro
The provided testcases are soooo bad
Yes, A and B are harder than C and D1 lol
so true!
hell no bro i get b is heuristic-ish but a u can just bruteforce moves
thanks whoever left the link to the song in prob C statement
Why is this user disabled? It's a genuine account you can verify.
Account :- abc_2002
This was my alt account since a long time. You can verify the problem E submission of today's contest it's a genuine one. I started solving problems from E as E was 2000 points and was under my limits.
Created testing_stuff just to post this and bring this to notice.
Please look into this concern. I want abc_2002 back as I have lot of memories with the contests attempted back then from abc_2002.
Please look into this
We're all degradities
I hate problem setters
Your profile pic expresses that feeling very well
C was easier than A
absolutely not
A,C,E all are actual shit in a kettle, zero thinking all pain
i agree
A was very tricky..... took me 2 WAs :( (could've solved other problems but had to go outside)
At the start of the contest there were 300 was and 70 acs
If only people actually tried to solve the problem instead of guessing the answer from samples...
it was ~23% success rate at the start (~80% fail rate), i think early problems were disappointing! I think most ppl were guessing the answer from the samples in the start.
Most strong participants expect A to have no edge cases that aren't exceedingly trivial or covered in the samples, it's a precedent that's been set for so long. I understand the motive behind breaking it but ultimately it makes the contest worse
That's too bad. If you want to guess the answer from samples maybe Codeforces isn't for you. Go solve puzzles instead. If you got punished for doing so with a WA verdict maybe it's deserved.
unsurprising W from QED
Hard disagree, that's what CF has been about for a long time.
Just say u suck, they were all easy except E
"shit in a kettle" sounds familiar to me...
Sample tests for A, C and D1 sucks imo
Good problems but tricky implementation and edge cases, wrong answers cost me a lot :(
wtf are you doing here Ethan..
Nice problemset. Could solve only 5/10 :(
solved A and B but no C feels so bad :(
Weak samples in multiple problems.
How to solve E?
lol D1 is sh1t
Realize you can just do two pointers and sparse table then spend the next 2 hours losing your mind and stacking wrong answers
100% not intended
Mb, thought I was right because it's very prone to one off errors and most of my friendslist was stacking WAs
Deleted
E solution
395035535
395073266
you can represent the rbs as a tree, then you have to get the longest sequence of nodes such that the nodes are the leftmost children of their parents. For this, while iterating through the bracket sequence, keep track of the current open bracket, how many closed sequences are there before it and how many closed brackets came after it. then you have to check if you can remove all these nodes i.e. total nodes are <k. or if you cant, perform binary search to find how many nodes you can remove.
Represent the RBS as a tree. Then, the operation simply deletes a leaf and then attaches the rest of the tree under a node. You need to maximise the length of such a path: u -> left child of u -> left child of left child of u and so on. Suppose, you want to make a path from u onwards the answer. Then, every sibling subtrees of descendants of u need to be deleted. We can use prefix sums for these and use binary search to get the earliest u for the current v such that P[v] — P[u] <= k, where P[x] is the sum of all the sibling subtrees of all the nodes from the root R till x with P[R] = 0. The other candidate answer is a path downwards from R. We can delete k other nodes to maximise its depth and make it depth + k and cap it at n / 2, since the operation always preserves n.
Solution we are looking for, ((i.e some string containing maximum number of consecutive opening brackets)) can be of two forms. Either - first opening bracket of the solution corresponds to one of the opening brackets in the original string. Let's call this "non-moved case". - OR first opening bracket of the solution corresponds to some opening bracket of the original string moved to the front. Let's call this "moved case".
In both cases, let's assume that our original string is zero-indexed.
Let's consider "non-moved case" first. Iterate over indices corresponding to the first opening bracket of the potential solution. Call this index A. For each A, iterate over indices corresponding to the last opening bracket of the potential solution. Call this index B. We can have a valid solution with this (A, B) pair only if - number of closing brackets from A to B is at most K in the original string AND B is less than the index of matching closing bracket of A in the original string. Total number of opening brackets in such a potential solution would be (B — A + 1) — (number of closing brackets from A to B) * 2. So far this is of O(N^2) complexity. Now, let's notice that [(B — A + 1) — (number of closing brackets from A to B) * 2] is equal to [[B — (number of closing brackets from 0 to B) * 2] — [(A — 1) — (number of closing brackets from 0 to (A — 1)) * 2]]. So, let's define for each index X, F(X)=X-(number of closing brackets from 0 to X) * 2. Now for each A, we are interested in such a B that F(B) — F(A-1) is maximized. But again, B should be such that, - number of closing brackets from A to B is at most K in the original string AND B is less than the index of matching closing bracket of A in the original string. Such set of B's for given A, form continuous sub-string of the original string, and can be computed using stack and two-pointer approach, as mentioned in the comments. So we are looking for maximum F(B) for given A, since F(A-1) is just constant for given A. Which corresponds to maximum range query for F. Which can be done using sparse table, since F is constant. This will give O(N*logN) complexity.
Let's consider "moved case" now. Instead of iterating over first opening bracket of the potential solution, now let's iterate over the last opening bracket of the potential solution. Call this index B. To result in "moved case", we should move all closing brackets from 0 to B. Let the count of all closing brackets from 0 to B, be C. We can have valid solution with any B only if - corresponding C is at most K. For this setup, we need to remove first C closing brackets in C operations, and we will end up with (B + 1) — C opening brackets in the prefix. But we have extra (K — C) operations left, so we can increase the number of opening brackets in the prefix by applying those extra operations one-by-one to eligible indices with (I, I+1) where I > B. But the answer should be at most N/2 obviously. So for given B with corresponding C, the answer is minimum((B+1-C)+(K-C), N/2).
We need to pick maximum of "moved case" and "non-moved case"
WAforces
edge cases assemble
Problem B is a WA nightmare
cool contest!
chromate orz
a nice round:)
gg!
How to solve D2 :'(
why is system testing so much faster than before?
Lord Verity can keep D2. I’m taking my 2000 points from E and going to sleep. XD
C is easier than B
I really enjoyed this contest, though I personally found D2 difficult. Something is coming in three days.
What's with the rating changes for the previous round? My contest history still shows a place from before removing the cheaters.
System tests finished faster than my brain trying to process D2.
jeez just say yall are jealous... (edited)
congrats
tyy!
Round is fire! Truly liked it. But in my opinion, A-D1 is a little bit easy.
I enjoyed the problems very much! They were very diverse.
Solutions:
You can essentially treat the operations as either: insert a
(at the beginning, or delete a). This reduces the problem to two cases. The first case is to take a prefix, delete all)s, and then insert some(s at the start using the remaining operations. This case's answer can easily be computed in an $$$O(n)$$$ sweep. The second case is to take any substring with at most $$$k$$$)s and delete all of them. The most number of(s in such a substring can be easily found using two pointers.The maximum of these two cases is the answer unless first case results in a value greater than $$$\frac{n}{2}$$$, in which case the answer is $$$\frac{n}{2}$$$.
For $$$n=3$$$ we can use the sample, so we focus on $$$n=20$$$. Let us first solve for a $$$1\times 20$$$ grid. Since our direction only depends on the count of 1s, let us use L if there is a 1 and R otherwise. By placing a 1 to the left of the target cell (if that cell exists), this solves the single row case.
Observe that this solution only requires the states for $$$0$$$ and $$$1$$$ 1s. For the full solution, we can allocate the remaining states such that the first $$$n-1$$$ moves are U and D, so they can reduce the grid to the single row case which we have already solved. To do this, let us move D if there is an even sum greater than $$$1$$$ and U if there as an odd sum greater than $$$1$$$.
Note that since $$$n$$$ is odd, deleting an all-$$$1$$$ row doesn't affect the parity of the sum. Hence, we can use a similar trick as above, by using the rows adjacent to the target row to adjust the parity such that:
This requires at most two additional 0s (with two only being needed if the target row has $$$n-1$$$ 0s), so this solution uses at most $$$n+1=21$$$ 0s.
Consider the following traversal of the tree: write the current node's value, then, if that value is $$$0$$$, traverse the left subtree, otherwise traverse the right subtree. Then, traverse the other subtree. On this new traversal, the operation just toggles a single value, so we can use any 1-bit error correcting code to get AC.
What about D2? What's the strategy after you find the components which have the same labels, using xor hashing....
The components are either nested, or completely disjoint, no partial overlap.
I tried doing greedy, pick the largest component, and 2nd largest component, and add a range to their endpoints, and hence reduce the components each by 1. If only one component remains, then solve it like D1
But I'm ending up using more number of ops.... I saw some binary lifting in tourist's submission. I wonder what....
And for E there's a nice way if look at it as a tree... You want to maximize the depth of the left most leaf...
Juicy problems
But what's verity?
Minecraft mod
During the recent WorldQuant Round 1 (Codeforces Round 1128, Div. 1 + 2), I noticed that the code of user TaZinh shows signs of being written by two different people or of using an LLM. Specifically, in particular, for problem G 395031633, the code he submitted follows a completely different form compared to his other submissions 395007110. I sincerely hope that the administrators MikeMirzayanov, awoo, KAN, and the contest organizing team SpyrosAliv, ttamx, omsincoconut, etc will permanently ban this user.
Do we really have to ping the admins? I'm sure they get tons of reports and I find it more likely than not they look at very few of the reports themselves. I'm sure they are aware that there are many cheaters that go undetected and reporting individual cheaters usually only means they will make another account with an even lower rating that takes even more rating points out of circulation from genuine users. Wouldn't we rather the admins spend their time coming up with other improvements to the site or trying to fix the root of the problem rather than these tiny one off hard to investigate cases that in the grand scheme don't improve things?
Editorial when...
Did anyone here solve G by persistent trie ????
D1 shouldn't have existed. E should have been D, and D2 should have been E.
give editorial asap...
Hello, my submissions have been stuck "In queue" for more than 5 hours.
Handle: ZENITH Submission IDs: 395068601, 395070438, 395071370, 395084278 Problems: 1791C (Prepend and Append), 1788A (One and Two)
Could someone please check this? Thank you.
this was one of the most fun contests ive ever attempted
originally i was going to praise the questions for certain reasons, but i dont wanna spoil and/or reveal anything
very pretty questions, thank you authors
i dont get it, all i did was say i liked the problems and thanked the authors
Weak samples, stacking WA2 in my friendlist T_T
Why is "verity" here?
Do you know if any editorial was created? I didn't find any.
Editorial when
https://codeforces.me/blog/entry/157917
say the thing
Maybe a personal opinion but I think C was much easier than B. I think some people found it harder because they thought it was DP or something? I solved it with some casework.
Subject: Appeal Regarding Code Similarity Warning and Skipped Verdicts — Problem 2261A
Dear Codeforces Administrators,
I am writing to respectfully appeal the code similarity warning I received regarding my submission to problem 2261A.
My submission ID: 394979994 Other submission IDs mentioned in the warning: 394979994 and 395028602 Other participant handles mentioned in the warning: "pookie_venom" and "thesilentghost07"
I received a notification stating that my solution significantly coincides with another participant's submission. Subsequently, all of my submissions in the contest received the "Skipped" verdict. I am concerned about the implications this may have for my contest participation and Codeforces account.
I would like to explain my situation as accurately as possible.
I wrote and tested my solution myself using CodeChef's online compiler and then copied the code directly into Codeforces for submission. I did not knowingly copy another participant's solution or intentionally share my code with anyone.
I am confused about how identical code appeared under another account. One possibility that concerns me is unauthorized access to my code. The other participant appears to be a student at my college, and I wonder whether my code might have been accessed while I was away from my computer. However, I did not witness such an incident and cannot confirm that this is what happened. I do not wish to make an unsupported accusation against anyone.
At present, I do not have conclusive evidence explaining how the matching submission occurred. Nevertheless, I want to cooperate fully and provide an honest account of what I know.
I understand that Codeforces takes plagiarism and unauthorized code sharing seriously, and I respect the importance of maintaining fair competition. I sincerely request that the administrators review the relevant submission timestamps, source code, and any other available information that could help establish the circumstances of this incident.
I would also appreciate clarification regarding why all of my submissions received the "Skipped" verdict and whether my participation or rating is affected by this decision.
I assure you that I am willing to cooperate with any review and provide any additional information I can reasonably obtain.
Thank you for your time and consideration. I respectfully request a fair review of my case.
Sincerely, pookie_venom
Bro started the blog with saying "Hello" in all languages except "Hello" itself.
Because those are the mother tongue of the authors!
Hello Codeforces team,
I recently received a notification regarding my submission 394999540 for Problem 2261B, stating that it significantly coincides with another participant's submission 395001708 (AkhilAlgo).
I would like to explain my side of the situation. I wrote and tested my solution in VS Code before copying and submitting it to Codeforces. I did not intentionally share my code with anyone.
My submission was made before the other participant's submission, as can be verified from the submission timestamps. I also had three wrong submissions during the contest. I understand that these facts alone do not establish the reason for the similarity, but I believe the submission history may be relevant to reviewing the situation.
I have checked the Local History available for my C++ file in VS Code and found entries from around the contest period. I have preserved the relevant versions and can provide them if needed to help clarify my coding timeline.
I would also like to mention that the other participant and I attend the same college, although I cannot confirm whether this has any connection to the similarity. I do not want to make unsupported assumptions about how the identical code occurred.
My submission has also been skipped. I respectfully request that the team review my submission and the available evidence, including the submission timestamps and relevant development history, and reconsider its verdict. If the review confirms that my submission complies with the contest rules, I would appreciate it if the appropriate verdict could be restored.
I respect the rules of Codeforces and take this matter seriously. I am willing to provide any additional information necessary to help clarify the situation.
Thank you for your time and consideration.
My submission: https://codeforces.me/contest/2261/submission/394999540
Other submission: https://codeforces.me/contest/2261/submission/395001708
Congrats kevin :)
Most deserved rank update I've ever seen.
orz kevin
I dont know why my code got flagged and i got marked with plagiarism the code to solve D1 is simple and it might have been trivial to many others if i had fully understood how to solve it i wouldve solved D2 also this is my beginning stage and my code got flagged with someone who i dont even know how do i get my rating back
Congratulations to the winners! Shortly you will be contacted via private messages with instructions to receive your prize.
UPD: This list is preliminary and may be subject to change following a thorough review to identify participants who have violated the competition rules.
Congrats to turmax