Hello, Codeforces!
NemanjaSo2005 and I are glad to invite you to Codeforces Round 1019 (Div. 2), which will start on Apr/21/2025 17:35 (Moscow time). You will be given 6 problems and 2 hours to solve them.
The round will be rated for participants of Division 2 with a rating lower than 2100. Division 1 participants can participate unofficially.
All problems are invented and prepared by NemanjaSo2005 and me.
We would like to thank:
MikeMirzayanov for the Codeforces and Polygon platforms!
maomao90 for his great coordination of the round!
Alexdat2000 for helping translate the round!
prvocislo for being the MVT (Most Valuable Tester)!
A_G for nutella testing!
milisav, N_z__, _istil, TimDee, culver0412 and Error_Yuan for red testing!
Phantom_Performer, RTE and Friedrich for purple testing!
beaten_by_ai, larush, Acanikolic73 and AlphaMale06 for blue testing!
You for participating!
The score distribution is $$$500 - 1000 - 1500 - 2000 - 2750 - 3000$$$.
We hope that you will participate and enjoy the round!
UPD: We are aware of people cheating on problem F. We are looking into it and are going to make sure to ban as many of them as we can!
UPD 2: Editorial
UPD 3: Congratulations to the winners!
All participants:
Rated only:








Blagoj NemanjaSo2005 orz
Orz
all testers and authors orzzz
stop this cringe orz thing please
What does orz mean?
Go to few comments below
orz means on my knees.It's a pictographic language,like a people kneeling down.'o' is like the head,'r' is like the arms and 'z' is like the knees
As a participant I would expect the problem statements are also short like the announcement, GLHF
As a tester, this round has cool problems, and I found one of them especially nice.
beaten_by_ai orz , remember you from IICPC regionals
Oh right, I remember you as well. Cool.
Blagoj wtf strong
Blagoj orz
As a tester, I had fun testing and I hope you feel the same participating ) Good luck!
How to contribute as tester. is there any blog in codeforce to explain it?
Know some author and be invited to test the round. There is also a testing server where before you could join by being trusted by a tester, but now I think it has to be a coordinator or something.
omg epic Blagoj NemanjaSo2005 crossover orz
as a tester that contributed basically nothing, Blagoj NemanjaSo2005 orz
As a participant, I hope that in this contest I'll solve two problems quickly.
My expectations are like: - Solve 2 problems - Close the browser
fellow inabakumori listener spotted, i for one hope ure contest goes gr8
as a participant, I hope that this isn't another Neowise Labs contest for me :)
Contest announcements should be on the front page right? I wonder why this one is not there, even when it's a rated contest.
demoralizer orz
whats orz?
see this https://mirror.codeforces.com/blog/entry/110951?#comment-988719
Still confused lol
it looks like a person bending down on their knee...
we use this to show respect to someone.. like bowing in front of them
Okay Now I got it thanks orz
ha ha . thanks.
now guess what is OGC( ̄▽ ̄)
OGC is a brand ????
lying hand job.
O is head,C is leg,you will see…╮( ̄▽ ̄"")╭
orz means on my knees.It's a pictographic language,like a people kneeling down.'o' is like the head,'r' is like the arms and 'z' is like the knees
It's the third post on the front page
I wrote question D in my dream!
ABCD speedforces
But I was blocked by human-machine verification when I was trying to submit B,and it took me about 20 minutes.Otherwise my rank could rise to about 500,and I won't go back to Expert today.QAQ
As a 1409-point newbie, I don't want to drop down to Pupil, please...
its part of the journey... GLHF
No, -20 point :((, I was wasted my time in wrong solution in C
oh no!!! I got -92 if you want to cry together.. ;(
.. keep practicing and don't worry too much over the rating on the next day after contest.. .this will take away the joy of competitive programming
We are gonna kill it in next div2 round. I hope you have a happy and cheerful day ahead !!!
I want to know how some people submit their solution within 30 sec of starting of the contest? can -any one explain please ?
good internet + speedforces
what's speedforces?
when question are too easy like q1 was too easy I took 2 min only due to (externalforces)
Insane jump in difficulty when going through questions like AB are too easy can be done quick but the jump in difference from B to C is too big.
Read this blog
can i reach green?????
1k pass D and 150 pass F, THE CRAZYEST LLM CHEATING ROUND, I will get -100 delta soon :(
UPD: I test chatgpt o4-mini(free) after the round, and it solve F in only 50 seconds!!!
same... it was a WA forces for me
Please do not discuss anything about the round before it finishes. Yes, it is 10 minutes before, but you still cannot discuss it.
We are aware of the situation on F and are looking into it.
Oops, I'm sorry
Remove all cheaters Please.
the amount of newbies in top 50 is crazy
huge -ve delta incoming....plz kill me god -_-
ImplementForces CheatForces
I agree there is more implementation than usual, but I hope not too much. We cannot do much about stopping the cheaters other than punishing them after they cheat.
Can someone explain why Tier_3_failure was banned? He is one of the good coders in 2025 from Canada. What was the reason behind disabling his account?
Also, oreg0na1 seems to be clearly involved in cheating.
When questions are formulated and implemented without ideas, AI easily solves them (even the worst ones)
There is currently no other way to deal with AI
I make problems for humans, not for AI. I know it's a controversial topic, but my take is that CP is supposed to be fun for humans!
I had fun solving C and D
I'm glad you liked them. But please do not make such comments before the contest is over.
what was C? was it like :
median <= k possible iff number of elements <= k are >= 2.
get the max and min index of these elements which are <= k. let them be l and r respectively.
check if any 0...i or i ... n (where i is between l and r) has a median <= k. if yes then ans is yes thats because we can always chose that (the range that i mentioned) subarray and take the other element as l or r and since 2 out of 3 elements are <= k the median is always <= k.
I posted the editorial. You can find the link to it in the blog.
Until now, 147 have solved F, and 129 of them are rated. I suggest that Div2 can be changed to 2100-rated and above, so that it reflects our actual level.
Seriously, E is a very simple question relative to F. I don't think banning everyone who solved F but didn’t solve E would be inaccurate.
They didn’t even try to hide it – that's what pisses me off the most.
I didn't look into status page to check submissions: I saw disbalanced stats on F in overall stats and opened it as a next one. Based on scoring I thought they should be relatively similar. Even keeping in mind that someone is doing gpt-submissions, it still made sense for me to read it first: if the task is solvable by llm, maybe the statement is clearer than in E, and this is important for problems with close scoring.
I havent solved F but it was a close call. So I believe this statement
I don't think banning everyone who solved F but didn’t solve E would be inaccurate.is a bit too much: some people's strategy definitely was affected by standings.However I agree that the situation is a ridiculous one.
I think that is why F probably has more legit solves than E. I can surely see F being easier than E, but not by like 500 rating as it is predicted.
You guys are right. Maybe because I prefer construction questions, I quickly found out how to do E but I had no idea about F. It is true that someone may followed the scoreboard and did F first (that actually happened to me)
I think those who solved F but not E need to be taken action: 1. Grey name 2. Lots of GPT-style comments in the code 3. Didn't even solve D (or C)
It's possible that CF will be the next leetcode, where GPT dominates the contests. Hope to see some action.
ClarificationForces
A<<B<<<<<<<<<C
got stuck at C. How to solve C ?
so because median is at
ceil(m/2)and the limit is actually<= K...to quickly say for a range if median is
<=k.. you can just count how many elements are<= k.. .if that>= len/2this subarray has a median<= kso imagine we call subarray with median
<= kto bevand> kto bewwe need to find the pattern
vvworvwvorwvvvvwandwvvare same... just reverse the arrayfor
vwvI calculated smallesvin prefix and suffixto make it easy to count elements
<= kin a subarray ... I replaced all elements<= kwith1and>kwith0now
vsubarray hassum >= 0.. and I solve everything I mention aboe using prefix sumI did same using ordered set to search in logn time complexity but getting WA in test2
https://mirror.codeforces.com/contest/2103/submission/316591716
ordered_set can only contain distinct elements and u can use two multiset (rolling median) to find median of any array but here we only needed to know if median will be <=k so we didnt need to use that
reversing array was kinda smart , finding vwv was easiest part of the problem
oh no .... problem B was good case work and I messed up.
What's wrong with problem F?
I enjoyed F. Tried multiple different approaches until I thought of the right one
Edit: Why am I downvoted to hell
Cooked in C
https://mirror.codeforces.com/contest/2103/submission/316591716
Why am I getting WA on test 2
Input:
2 2 1 1 2 2, k=1There is no solution but your program outputs YES
c was overkill
How to solve C? I spent 1.5 hrs for debuging my solution for C.
my approach https://mirror.codeforces.com/blog/entry/141912?#comment-1268096
Think it from this perspective : for a segment to have median <=k , the count of elements <=k should be greater than the rest of the elements of this segment...
Problems are: Ridiculous, staged, and without ideas
If you cant ask questions, dont hold a contest!
Wondering why my D solution(316582962) keep getting WA on 2, I've spent almost 1h on finding the reason.
rip for my -40 delta, im getting back to expert...
Try this:
I think this is wrong: (o && x!=v[i][o-1]+1)
After 1 finished, you check if 2 is connected. You should use linked list.
Thank you.
After looking at it for a bit, it seems our solutions use the same basic idea. However, it seems you're missing some casework.
Firstly, in your for, you look for an index $$$i$$$ such that $$$cur_{i - 1} + 1 \lt cur_i$$$ between your indices as the reorientation point for the sum (right, cause we want to form a structure akin to the following: "\/" or "/"). But, what if the values between $$$cur_{i - 1}$$$ and $$$cur_{i}$$$ are all less that the current value that we're checking? In that case, you reorient yourself at the wrong point (as one of the values in that iteration could become either a local minima or a local maxima). Therefore, you need to find a mechanism of selecting that index $$$i$$$ such that the values between $$$cur_{i - 1}$$$ and $$$cur_{i}$$$ hold with the previously stated condition.
Secondly, I think you aren't handling the case when we shouldn't reorient ourselves at any point properly. Anyways, I think if you manage to rework that previous case (the solution to that part isn't as bad as it sounds) you will be able to find all additional janky cases.
how to solve B plz anyone share the approach...
try to break the string into components of 0's and 1's and count them rest is just casework
I am somehow hoping there is some neat observation which avoids a lot of case work :P
I got cooked in all the casework :(
looks like I wasnt alone
I want to forget about this problem B ... aaaahhh!!!!
Same got 2 wa's before ac:(
only 2... those are rookie numbers... :P
I think too much before submitting that's why I am stuck at a particular rating bcs of my speed and this habit lol.
I see your profile
you have good consistency and good number of problems solved, please try to solve only those problems which are above your rating when you are practicing .. i hope you will get more positive delta soon
please remember everyone goes through this where they keep getting stuck at a problem .. like today you get stuck at B then for next 6 months you keep getting stuck at C ... lol
Thanks for the advice will follow that for sure:).. good luck to you too, I hope you reach master soon
wow, thanks <3
B felt weird this time...i couldnt get any idea after reading the problem,was just tinkering with the samples the whole time ,still couldnt get the right approach..:(
I am hoping editorial will tell us some neat trick .. else I will cry more :(
Maybe look at my B submission? It was like 10 lines or smth and I didn’t really notice any casework, I ended up with two cases: one to decrease the ans by 1, and one to decrease the ans by 2. Your sol looks overcomplicated. 316703884
whoa this is brilliant, I aspire to achieve this level of clarity.
I notice you talked about $$$s_1=1$$$ or $$$s_1=0$$$ like it was something you had to consider in another comment, but I think you should always avoid casework unless you know why it's casework; I thought that was going to be a pain as well until I tried to think of why it had to be a special case. Then I realized there's nothing special about it, we can just say $$$s_0=0$$$ to automatically handle us starting on $$$0$$$.
Then again, I was practicing problems in the archive while you were actually competing so maybe I would've went down the same bad path under time stress.
yeah, didn't get the idea to pre-prend '0' to make both cases similar :(
I did case work .. a lot of case work
but basic idea was if you switch the string
l to r.. only change happens in the ends ... everything in between remains samenow there are cases where l = 0 or 1 .. r = 0 or 1
now when your rotate you want to place 0 with 0 and
1with1at the end pointsbut if you bring
1at the beginning you don't achieve anything because you have to do one move anywaysso you want to bring
0to first slotall these cases and finally I got pretests passed after a lot of wrong submissions
hoping it passes system tests
Lots of grey got AC in F...
whoa I saw it just now... how did that happen
GPT definitely. Lots of them solve F but stuck at E, which means F is somehow a classic problem that GPT has been trained.
oh no !!! yikes ...
solving A, B : Is this div 3 or what!
solving C: now, I get it :(
Just have a small comment on D, I liked how the input stated that a[i] <= logn, because I had comment on last round that D didn't state that n will be odd always.
D today could have said that a[i] <= n, and then all the testcases will not exceed logn (because it is impossible to be > logn), but for me I see that contestants should not have any assumptions on the input so thank you for stating the actual values in testcases
was this fact useful in solving it... I was not able to solve it anyways :( ... i figures step number has to be used in some kind of comparator, but couldn't build the answer for indices having same step of removal :(
It's really useful to know that iterations are <= logn, so you could write an actual implementation of the process and it will be in nlogn
ok, thanks... hoping to get a good editorial so that I can upsolve D.
And actually the proof of having the iterations <= logn is cool, you cant have more than n/2 local minima/maxima in an array of size n, so you always remove at least half of the array
oh wow, that is cool !!
I guess we can make a problem div2B or div2A ( don't know) in future where we count how many steps it takes
i thought F was a well known problem
uss bro
After I hard working and solve problem D and find out that problem E is hard to implement. I notice that I can gain some score in the round. However, the predictor told me there are so many guys better than me.
Why? It is because that zombies walk from graveyard in the Easter? (Easter = 复活节 in Chinese)
Find cheaters on the post: https://mirror.codeforces.com/blog/entry/142150
Thank you?
I just bombed problem C.
I hope that NemanjaSo2005 could ban cheaters on F as soon as possible.
Yes please! Its simply unfair for the rest of the participants.
Trust me, I hate them as much as you all, if not more!
I trust you. I could be close to Master after this contest if it hadn't been for cheaters :((. I wanna to get 2k1 for so long, so I feel thankful if you could do it. Thank you for noticing about this situation.
As a tester, we are aware that today (just like in any recent round) a lot of people have used LLMs, which is against the rules. It is the reason behind the inflated number of solves on the late problems.
NemanjaSo2005 and Blagoj know about this issue. They were working hard on finding and reporting these cheaters the whole round. Even now, instead of taking a break after months of working on the round, they are working on the situation. The cheaters will get removed soon, but the priorities right now are publishing editorial and system testing.
Some people are blaming the authors for things that are out of control. Let's focus on the positive aspects of the round instead, because after all, Codeforces is just a cool hobby we have. If you enjoyed the contest, consider supporting the authors. You can comment about the problems you've liked, what you've achieved today, or even just upvote the blog. It may take just few seconds for you, but it means a lot to the authors who spent months making the round as good as possible for you, the Codeforces community.
I dont think authors should be blamed in any way for this...
only cheaters should be blamed.
Is pragma really that powerful? I have heard that pragma can usually speed up performance up to 2x or 3x but in my situation is a whole 20x
First code (TLE)
Second code with pragma (AC, 62ms)
Both code are exactly the same, except for the first line
How is this possible?
oh wow !! is there any reading material to understand what is this sorcery.
I'm guessing that with -O3, the compiler pulls
a[i - 1] != a[i]out of the inner loop, changing the time complexity from $$$O(n^2)$$$ to $$$O(n)$$$.If anything I'm surprised that it doesn't do this optimization at -O2; that expression is pretty obviously loop-invariant so if it fails once you can just break out of the inner loop immediately.
I was a bit surprised by both C and D.
For C, I thought the solution could just be implemented with just two pointers and a couple of counters. And although maybe that solution could work, after staring at it for way too long, I figured that some more interesting properties (well, convert array into 1s and -1s, get prefix sum and suffix sum, and etc) would be necessary (which was in fact the case and thus produced a very clean solution).
Then for D, I instead got scared and thought that today was my bonedead day. Then, I saw the necessary observation, implemented it, got WA on the first test case, realized I needed to just flip the sums with relation to the fixed value (-1), and voila.
So overall, I quite enjoyed the problems (A through D)
I see that you like to live dangerously
D was nice, i implemented a toposort solution (wasted alot of time). then realized a very simple solution.
Exactly same for me
Originally, that was intended, but we discarded it due to being annoying to implement.
Thanks to younesg, we now know that OpenAI's claims about their model o3 having a rating of 2700 are false. It's clear to everyone that he's using LLMs to cheat (even in today's round), yet his performance is still far from GM level (He was ranked 2nd once lol, but that was only because the problems were standard)
I'm honestly surprised he hasn't been banned yet, even though he's been caught cheating in multiple rounds and many of his submissions were skipped.
I used to enjoy watching him waste 2 hours every contest benchmarking different LLMs, but now that we know o3 is nowhere near GM level (thanks to him again), he's not really useful anymore. So at this point, he might as well just get banned.
lol
o3 got nerfed now. But yes, it still has too much of a varied performance (for example, it sometimes fails on 1600 rated problems, and sometimes can do 3000 rated problems (when they're standard or involve implementing some data structure or something)). Another point of note is that o3-mini has gotten GM performance before, so we cannot judge the skill of LLMs based on only one contest, we need to take the average. In the last contest, o3 got around IGM performance (ABCDEH), due to already existing problem H, so it can sometimes get much better results than GM performance also.
Yes, I do agree. But when I say someone has an IGM level, it's more of a point of view from a human perspective, not just about the rating itself. Getting WAs on test 1, getting hacked because of using unordered_map, and often failing on easy problems—this doesn't look like IGM level to me, even if it managed to achieve the IGM rating it still not and IGM.
OMG, first time among the top 5! Happy! Still I've got no idea about F which disappoints me.
ORZ!
orz! you must thank jiangly orz
Only thing is to give plag to rated participants who solved F but not E
Though I hate cheaters, not all of people who could solve F but not E are cheaters, as F could be standard.
Ohh, F is standard? Sorry, actually I don't know that
I like today's problem F, thanks for the great problem :)
Really difficult but interesting problems. Thanks for the round
can anyone explain why it says -2
but it was actually 
C is easier than B, case work in B was really tough, wasted more than an hour on B
Can anyone hack my solution for C since I believe that it has a worst case complexity of O(n^2). 316589874
A good news and a bad news for me: solved D 3min after contest.
Any idea how to approach poblem B ?
editorial is out.. you can check it here https://mirror.codeforces.com/blog/entry/142149
Read about Exchange Arguments
for C i didn't do anything fancy. didn't convert to 1/-1, didn't use two pointers, partial/pref/suffix sums.
i just checked if a subarray was possible from the beginning and then from the end:
if both of them were possible : YES both of them not possible : NO
one possible :
check if a middle array is possible : YES ? NO
did i get lucky with testcases or something??
my submission
I have the same solution as you. It's just greedy + casework. My submission 316584294
What the hell, AI in the top 5? 316553220
I am so worried about the impact of AI on online competitions...
It’s already had a massive impact. I just hope cheating detection becomes more sophisticated to catch up with the cheaters.
My Solution for Problem E (Almost Completed During the Contest, What a Pity)
Step1: Assume a[s]+a[t]=k, perform operations to make a[1]+a[n]=k.
a[1] ... a[s] ... a[t] ... a[n] -> a[1] ... a[1] ... k-a[1] ... a[n] -> k-a[n] ... a[1] ... a[n] ... a[n]
Step2: Arbitrarily swap a[x],a[y]
a[1] ... a[x] ... a[y] ... a[n] -> k-a[y] ... a[x] ... a[y] ... a[y] -> k-a[x] ... a[x] ... a[x] ... a[y] -> k-a[y] ... a[y] ... a[x] ... a[y]
AC Code: 316605252
Can you give me some ideas for question E? I still haven't solved problem E.
we don't want that much powerful cheating detector, most cheaters are obvious for now, just get them
hello my fellow competitive programmers, this morning i was looking for some youtube videos to understand and upsolve the problems which i could not solve in 1019 Div 2 contest, then suddenly i saw this youtube channel. this man has uploaded all the solutions till problem F excluding problem E, solved all of them, and i am damn sure he has cheated, also he runs a telegram channel which is mentioned in his youtube channel where he uploads the source code of all the problems, and he has just registered some hours ago, he is — 777dimasik777. and even if he has not cheated, whats the need to upload solutions on youtube and telegram during the contest. such people ruin our community and this platform. please, someone take strict action against such cheaters, so this platform is free from them.
Good evening everyone, This is my first ever comment on Codeforces and I had hoped it had been under better circumstances. I had recently received a system mail saying that my solution for problem D 316573346 had a lot of similarity from another user's Pratik__9284 submission 316588192. I was shocked by this claim as I had not participated in any form of cheating or sharing my code online. On looking through this person's profile I noticed some astonishing patterns which suggested this is not a mere coincidence. This person has gone from being a Newbie to a Candidate Master in mere 3 contests. I know it may be possible but it is highly unlikely that this person has gone from achieving a 12,953 rank a month ago to having global rank 7 on yesterday's contest.
I don't know exactly how this person got to access my code (Maybe from the lock & hack system) but I hope someone looks into it. I feel pretty bad since I don't support this unethical action which ruins the fun for other hardworking contestants and the problem setters (Blagoj and NemanjaSo2005) who contributed so much to bring us these new ideas.
https://leetcode.cn/problems/queue-reconstruction-by-height/description/ https://leetcode.cn/problems/group-the-people-given-the-group-size-they-belong-to/description/
I used the relevant parts of the above content as a reference.316584505 I don't think this is a violation. Maybe it's just a coincidence or a result of the leakage caused by using the public web-based online compiler. I read the code from the other party[submission:316548435] in the email and found that there are significant differences in naming styles and detail habits. This is not a violation of the rules. I hope to have the relevant handling revoked, and I will participate in the next competition in a more secure environment. ~~~~~ The following boards are derived from the two websites and personal summaries below /* vector<vector> groupThePeople(vector& groupSizes) { unordered_map<int, vector> map; for (int i = 0; i < groupSizes.size(); ++i) { map[groupSizes[i]].push_back(i); } vector<vector> res; for (auto& entry : map) { vector& group = entry.second; for (int i = 0; i < group.size(); i += entry.first) { res.push_back(vector(group.begin() + i, group.begin() + i + entry.first)); } } return res; }
int left = 1, right = n; for (int group : groups) { if (group % 2 == 1) { // 奇数组分配较大数值 for (int pos : groupPositions[group]) { elements[pos] = right--; } } else { // 偶数组分配较小数值 for (int pos : groupPositions[group]) { elements[pos] = left++; } } }
set available; for (int i = 1; i <= n; ++i) available.insert(i); // 处理某个位置后移除 available.erase(pos); // 查找连续区间 auto it = available.upper_bound(pos);
// 处理完所有组后分配特殊位置 elements[specialPos] = left;
bool cmp(const vector& a, const vector& b) { return a[1] < b[1]; } int intervalScheduling(vector<vector>& intervals) { sort(intervals.begin(), intervals.end(), cmp); int res = 0, end = -1; for (auto& interval : intervals) { if (interval[0] > end) { res++; end = interval[1]; } } return res; }
vector sortArrayByParity(vector& nums) { int left = 0, right = nums.size() — 1; while (left < right) { if (nums[left] % 2 > nums[right] % 2) { swap(nums[left], nums[right]); } if (nums[left] % 2 == 0) left++; if (nums[right] % 2 == 1) right--; } return nums; } */ ~~~~~
so many cheater in this round
After the cheaters are caught and removed, will rating be adjusted for all participants? For example my profile says my rank is X, but standings say X — Y (Assuming a good amount of cheaters are removed so far). Wondering if this change in rank also possibly means some +delta. Is there an estimate for how long this takes? (I know you guys are working hard, really appreciate it).
bssss_a cheater is on 3rd position,wow
If your level is not as good as mine, just say I cheated?
you don't even run your own code on your computer,you just copy from LLM and paste it and you are having pride on your skill (cheating)! Great!
hhhh. You need to improve your level. With over a thousand questions, you are still a Specialist
The rank on my rating board is different from the real one.