Hello, Codeforces!
eren__, sweetweasel, and I are glad to invite you to Codeforces Round 1024 (Div. 1) and Codeforces Round 1024 (Div. 2). Both rounds take place at May/11/2025 17:35 (Moscow time), and have a duration of 2 hours and 30 minutes.
The Division 1 contest is made up of $$$6$$$ problems, and the Division 2 contest is also made up of $$$6$$$!
We would like to thank:
- maomao90 for his wonderful coordination and huge help in preparing the round.
- Alexdat2000 for the Russian translations.
- Our testers: mmdrzada, N_z__, Hamed_Ghaffari, Shahrad_Mirzaei, RSAMSD, -this-is-obd-, AmShZ, AlefHeKaaf, beny_kh, Nariman_MT, sohsoh, Shayan86, Nimazare, Amoo_Safar, _R00T, Um_nik, AriaH, KiaRash24, AmirAli-Asgari, RadRah, NK_, FrontMan., Ali_BBN, AustinJiang, dshfjka, aram.hosna, arvindf232, larush for testing the round and providing valuable feedback.
- MikeMirzayanov, KAN for the amazing Polygon and Codeforces platforms.
- You, for participating in the round and gaining a positive delta!
This is our first (and hopefully not the last) contest on Codeforces, so we really hope you will like the problems. Don't forget to have fun!
The score distribution of the rounds is as follow:
Division 1:
Division 2:
In the end, here’s a behind-the-scenes photo of the authors putting in the effort to bring you a fun round!
UPD1: The contest is now over. Congratulations to the winners!
Div. 1:
Div. 2:
UPD2: The Editorial is now out.









As a tester, I wish the authors would win the IOI.
As a tester, I wish the authors would win the IOI. (and, of course, two of the testers :D)
LOL
Thanks a lot
wow are they IOI participant ?
I hope they get good results
Thanks my sweet student
take me as your student
why not ! of course.
do you take newbies?
yes.
So does that mean I can be your student?
yes again.
Thanks, Teach!
One can confirm by looking at the photo, that the authors are smart and good-looking.
As A participant I hope Enjoy.
A power of two round can't miss it, the next one will be 1024 rounds later
And the power is a power of 10, next time that happens will be 2^100, and universe might end by then
orz
as a none tester, I can confirm this contest will be epic
This would be my 100th rated round...Excited for this !
Hey bro quick tip: between rounds work on problems that are 200–400 points above your current rating so (1800 to 2000) for 50–100 of them until you can solve them quickly. This helped me a lot during my IOI and ICPC training when I was stuck at ~1700. Hoping for a +delta for both of us
thanks this was helpful!
Try maybe solving alot of CSES Problems too their is only 300 of em i did it all in a couple of months helps alot.
Thank you for your suggestions :)
i hope the round is strong strong
misha
Yay, my first Div1 contest. I'm so excited!
As a participant, I hope solve three questions and become a specialist.
Me, too.
And I hope everyone can enjoy the round with a rare index!
As a failed cyan, it's inspirational to see a lot of newbie prodigies AKing the contest I am sure that future of CP is in right hands ...
But I don't see 720 problems in the Div 2 round...
Wow 1<<10th contest
Another opportunity to lose rating!
wish to have non-negetive rating change :)
I wish to hit pupil :D
I solved 3 problems on a div 2 twice now and couldn't hit pupil. Better solve 4 next time....
Damn your crazy, you got 4
tyty, gl on reaching pupil soon!
As a potential participant, 720 problems in Div. 2 is kinda scary. Good thing it's 2:30 and not just 2 hours long.
Let's take out our horses for the cowboy round.
1024 is a very meaningful number,This contest must be very exciting !!!
I used to think top coders were nerds, but the image in the blog changed my mind.
The one in the top right looks like Berlin from Money Heist.
Bella Ciao
They're the biggest nerds I've ever known(top 2 in the pic). The kind of nerds who have 10 accounts to hide their progress from others and 1 has been studying for 7 years and the other for 4.
EL Classico or this contest? Hmm...
My first div 1 :) !
Codeforces Round
1<<10!Looking forward to a Wonderful Round :D
I think this is gonna be a speedforces round for Div. 2
What score actually is? Is it connected to the problem's rating?
Please don't get me wrong.
The score distribution will be very helpful if you actually care about the details:
But I'd suggest you to focused solve problems in order and ignore the hairy details for best practice atm. You might want to revise the details later, once you starting to getting good at it.
Is it forbidden to ask anything if I don't know something? Like, why am I getting dislike just for asking a question?
Probably because this question gets asked under every contest announcement, even though it's easy to understand what it is by searching it up
Well. I guess I'm a reverse nutella now.
@ of the guy in sunglasses?
Shoo
will i be green ,who cares i am from a warrior race
this is the second div 2 in a row where we have 250 on problem A
Congurats!It's round 1024!
good.
oh! the contest number 10000000000 -__-, i cant wait for it fr <3
CF round $$$10^{1010}$$$.
nice!
let us give this contest
1<<10upvotes to celebrate nice number for the round.Good luck, guys! I'm sure you've cooked a great contest.
I'm gonna cook inshallah
As a non tester, i was supposed to test but forgot, wish you a good contest
there's 720 problems in the div2???
edit: oops i just realized two people commented this before me... i'm unoriginal :(
Round 10000000000 is here!
Time to ready my a+b template because A is 250 points
I don't think it's an a+b problem, because last time I took a 250-point question, I only got over 90 points.
But you're in Div. 1 :)
Got me there...
Very nice LOL
Yeah,finally it's round 1024.And when will round 2048 come
Probably in 15 years =))
Hope to reach 1200+ again!
Just out of curiosity, why some rounds have unrated option but this one doesn’t?
Icpc style contests: div 3,4, Edu rounds do, Cf styles dont
Thanks! I wanted to participate in this round but I am 100% confident I won’t perform my best tomorrow; so unfortunate I will miss 1ll<<10
Thats not the round 1024, thats round 2^10
2^10 = 8, what do you mean??
I see what you did there!
the ^ is the exponential sign, not the bitwise xor operation
Thanks, I wouldn’t be able to tell otherwise!
That first photo straight up looks like Dagon's Domain Expansion — ocean vibes , domain expansion pose and all Gotta be Toji Fushiguro to clear it all up with zero cursed energy but max smoke
"The Division 1 contest is made up of 6 problems, and the Division 2 contest is also made up of 6!"
Why is the Division 2 contest made up of 720 problems??
.
But 6! = 720 ヾ(•ω•`)o
ha ha !!! noice.
haha (^_^)
Why no div3 contest? Its been quite sometime.
good luck
from the score distribution of div.2, it seems the speed to solve first three problems would be a major differentiator, and if solved 4th it would give much edge over other participants
i myself fucked up C! should have gone with instinct from the very beginning : (
I knew it so didnt give it :)
what problem rating should i expect for the first 3 of div2?
and hope to reach pupil in this contest..
A : 700 — 1000 B : 1000 — 1200 C : 1400 — 1600
You can check the rating of problems on Clist
okk, thanks
First time participating in a 1 << x contest >:)
2^10 congratulations!
As a participant, seeing Um_nik as a tester means useful algorithms.
Do testers decide problems ? That is the job of authors right?
As a tester, haji ajab cantesti !!!
eshgh kardi ???
asan benazam:)
KiaRez orz
eshgh
as a tester, i know problem A
and this is the answer of problem A:
cin >> q; while(q -- ){ cin >> n >> m ; cin >> r >> c; cout << max(r — 1 , n — r) + max(c — 1 , m — c) << endl; }
why would you say something like that?
It's not a good joke.I hope you're not a real tester.
bro he's on the list
Oh,it's bad.
No I have seen it, what should I do?! Should I give up A?
ig writer have many spare A problems
Sometimes I really hope my complain and downvote would make the comment disappear.
What was that. Very poor behavior. I hope its just a joke.
Happy round
0b10000000000!will manhandle this contest
Failed
I will forever in shame
Again 250 score for problem A!
I hope to not get minus on that.
Sorry Guys. I will watch El Clásico.
Why are the scores so strange today?
How long does it usually take for someone to reach candidate master on average? I've been participating in contests since the beginning of 2025, but I feel that I'm still far away :(
Hope to solve today's ABC as fast as possible.
Lets call this contest "The 10th bit"
Failed to start like Mbappe in todays contest...**Hala madrid**
rainboy orz
last submission 5s before the contest ends!
aaah!! couldn't solve div2 D... got messed up in case work. is there a simple solution ?
Fill the first $$$n-3$$$ places greedily
yeah, did that; but how to decide the order of nth and n — 2th term?
Parity of the permutation is invariant, so just compute it for the original permutation and one of these $$$2$$$ potential answers and using that, figure out which of them has the right parity.
this is brilliant, thanks.
someone else also mentioned this, I wish I could figure it out.
spent 1h30 searching for an invariant, didn't find one..
Ahh, I knew there had to be some invariant. I was stuck for almost 2 hours trying to "guess out" the most arbitrary property of the swap operation...
Could you please explain what do you mean by parity of permutation ?
It means the parity of the inversion count.
exactly one ordering among the two ordering of $$$nth$$$ and $$$n-2 th$$$ element is possible so if we keep filling in first $$$n-3$$$ places by continuous naive swapping; the array that remains in the end is the answer , but issue is how to keep track of the changing array within time limit , thing is I have figured out it is safe to assume that in one operation it is possible to swap $$$a[i]$$$ and $$$a[j]$$$ ,$$$a[i+1]$$$ and $$$a[i+3]$$$ where $$$j$$$ is any $$$index \gt i$$$ with the same parity as $$$i$$$
the sum of number in inversions in individual even and odd arrays % 2 before and after the rearrangement remains the same so if the sum of inversions in odd array and even array is odd then the smaller number will come at nth place else vice versa
yeah I figured that I just have to handle last 3 places.. and at max one inversion will remain in odd and even places total
but it seems in some cases you can still sort remaining positions by doing some swaps initially ( I think ).. couldn't figure out in what all cases it is possible to sort both odd and even position completely.
Hmm good point but I think the last three elements are already uniquely determined (not sure)
oh your pretest passed so I think you are right.. did I make a silly mistake.. nooooo!!!
Yeah,I reailze compeletly sort is worse at last.But I haven't understand the true way
Total count of inversions will remain same modulo 2 (For one operation it can change by 0/-2/+2/+4/-4 etc.). If we get a different modulo 2 for the greedy complete sort approach, just swap nth and n-2th positions.
Could you please provide the proof/intuition behind this ?
Proof of Inversion Parity
Consider a b c d -> c d a b
For element 'c', inv += (c>a?1:-1) + (c>b?1:-1) = {0 or -2 or +2}
For element 'd', inv += (d>a?1:-1) + (d>b?1:-1) = {0 or -2 or +2}
Proof of Greedy Selection
Position parity of every element remains the same (i.e. you can only move an element among the odd positions if it is initially at an odd place, likewise for even)
Further greedy selection possible for 1 to (n-3)th element
n-1th element already decided(greatest of its parity) so all that is left to to determine (n-2)th and nth elements(Among the two greatest values), which can be thus chosen to satisfy the inversion parity.
Note that say the two candidates for n-2th and nth values are x, y (x<y), then (x z y) and (y z x) would lead to always different parities of inversion, hence answer uniquely determined.
Much appreciated!
Could you please elaborate?
I couldn't solve too! I wa on 2 twice.Lastly,I found my solution doesn't completely right
You can sort the even and odd groups by just greedily moving the minimum in the suffix to this position. You know everything is sorted right now except positions n and n-2 because you couldn't do the greedy strategy on them. If n and n-2 weren't in sorted positions (in their group) you know that group has 1 inversion and the other group has 0 inversions. Otherwise, you know both groups have 0 inversions. Notice when you're doing the swaps, the relative parity of the inversions in both groups never change. If they're different parities, they will always be different parities. If they're the same parity they will always be the same parity. So, if they have the same parity initially, you can never get 1 inversion in 1 and 0 in the other (the only possible choice is 0 inversions in both even and odd group). If they're different you can never get 0 inversions in both.
oh I see... I think I get some idea.. thanks for sharing this.
In the end I think whole trick was can you sort those last two elements or not.. and I think your idea is a very simple way to figure that out.
guessForces in C... no idea why spiral printing starting at center passed pretest LMAO.
we would want 0 to be present in most of the subgrids as any subgrid without it would mex to 0, therefore we put 0 at the centre as this pos has the most occurrence of among all. now comes 1, we would like to put 1 such that the subgrid containing 1 and 0 are maximised, this would be subgrid 0 1, now comes 2 ,now we want number of subgrids containing 0 1 2 to be maximised, this can be achieved by enclosing 0 1 2 in a 2*2 grid, using this logic we can prove why spiral printing was the optimum sol'n.
oh wow.. I think this makes sense.. so it was kind of for any cell count how many subgrids this is going to be part of .. sort it .. and then put number in reverse order or something.
whoa thank you for sharing this .. I am sad that I didn't get any ideas for this.
yeah, say our pos is (i,j), number of subgrids this would be present in is i*j*(n-i+1)*(n-j+1), this is because we have "i" choices from top to i, (n-i+1) choices from bottom row, w.l.o.g we can say the same for j.
wow, so cool that you were able to think all this during contest time..hope you get positive delta and become higher rated than me.
Didn't think of spiral printing specifically, but that example input, even for n = 3, was a massive hint.
guess work=accepted in C for me
what did u guess
evrything LOL what i guess was you will start from centre of the matrix and start printing in spiral so,
i
0 1
3 2
6 7 8
5 0 1
4 3 2
6 7 8 9
5 0 1 10
4 3 2 11
15 14 13 12
in this way for any n this is what i guess and got accepted
I think printing as spiral starting at center works on pretests
first time I've seen a nice constructive problem :O
Great problems. Thanks
Can someone please explain C , i thought 0 should come in middle and 1 should always follow it
but kept getting wrong answer on pretest 2
this was my try :319285532
just spiral printing ,starting at center guess the answer and you'll get accepted.
how to do div1C?
Say the elements that occur at least twice are integers from 1 to x.
The first occurrence of each i, i<=x should be in a prefix,
and the last occurrence of each i, i<=x should be in a suffix that doesn't intersect with the prefix.
Now we start building the answer from an empty prefix and suffix and each time we extend one of them based on whose x is smaller.
The indices of the elements taken in the prefix should be subtracted from the answer.
The indices of the elements taken in the prefix should be a added to the answer.
for each iteration we say ans = max(ans, cur_ans)
I've done the building of the answer using a segment tree.
lemma: In an optimal pairing, $$$max_j$$$ such that j is the left of a pair $$$\lt$$$ $$$min_k$$$ such that k is the right of a pair.
For each index, we define $$$L_i$$$ as the biggest number $$$t$$$ such that you can label $$$a_{1,\dots, i}$$$ with $$$1, 2,\dots, k$$$.
for $t$ to be valid, you need every $$$1 \le k \le t$$$ to have at least $$$t - k + 1$$$ eligible elements, so $$$cnt_k \ge {t - k + 1}$$$ thus $$$cnt_k + k - 1 \ge t$$$, so maximum $$$t$$$ is the minimum value of $$$cnt_k + k - 1$$$ over all numbers from $$$1, \dots, n$$$. this can be handled using a segment tree, initialize the segment with the array $$$b = [ 0, n-1 ]$$$ and then loop from $$$1$$$ to $$$n$$$, when visiting $$$a_i$$$, add +1 to $$$b_{1, \dots,a_i}$$$, and let $$$L_i = min_{i = 1}^{n} b_i$$$.
Calculate $$$R_i$$$ the same from the suffix.
$$$T := max_{i = 1}^{n-1} {min(L_i, R_{i + 1})}$$$. The numbers of the pairs will be from $$$1$$$ to $$$T$$$.(This is reached from the first lemma, where $$$i$$$ is the splitting point)
Now start greedily pairing, add all indices with values $$$ \gt T$$$ to a set, and for $$$i$$$ from $$$T$$$ to $$$1$$$, add every occurrence of $$$i$$$ to the set, match the minimum and maximum elements in the set and remove those 2 from the set(they will have the value $$$i$$$ in the optimal array), and calculate the answer.
Instantly borrowed my own code at problem 2036D - I Love 1543 and saved implementation time at div2C.
why make us think so much in problem div2 A, we want to be happy while starting the contest please
I got 94 points at last,humorous
I was able to solve it fast, but still I felt a bit more effort than I expected :(
who else skipped C to solve D and then stuck at D and lose a lots of points ...
any second i felt im closer to answer of D but stuck after 1hr, realized i could solve C in less than 10 minute...
how to solve C .. did you figure it out or you guessed printing the spiral way ?
actually for any cell (x,y) i calculated how many subgrids exists which doesn't contain (x,y).
because you know if we set positions of 0 to be (x,y), we should have most subgrids containing this cell ( otherwise their MEX would be zero )
after finding how many subgrids exclude (x,y) minimized it using parabola's minimum formula.
then you get x = (n+1)/2 and y=(n+1)/2.
so i realized zero should be at center always, moreover, its subsequent numbers are better to be close to it, to maximize MEX for those subgrids containing zero cell.
its not really a proof but it was my intuition, then i guessed spiral would be the best solution. submitted and it worked
very nice, thanks for sharing your thinking .
Exactly, every moment i felt i am close to solving D but i was yet too far away, and exactly opposite for C, it seemed too complicated but was really simple
for D i only had 1 uncertainty about a[n-1] and a[n-3] ( zero indexed ). if i could somehow find them i could solve it. there was only two possibilities....
You count inversions to determine the ordering of those two elements
Oh it makes sense. Thank you
In D I declare the BIT array globally for fenwick tree and wasted 45 min to debug.
You could've also used alternative methods like merge sort or ordered set
Solution is fine but the problem was declaring an array globally and not making clear cause obvious WA as we have different cases in single testcase (t>1)
Can someone give a hint for problem E?
Say the elements that occur at least twice are integers from 1 to x.
The first occurrence of each i, i<=x should be in a prefix,
and the last occurrence of each i, i<=x should be in a suffix that doesn't intersect with the prefix.
Oh, I got it! Thanks!
What does the author wants to test by giving problems like Div 2 C .......
I personally find it a nice problem.. It was intuitive to have a spiral matrix because that's how MEX would be maximised. Though; it also took me long time and various other guesses to come up to the idea..
And this is not a coding test but a problem solving contest (nothing to be tested by the author). So, author wants to make an interesting problem not the one testing knowledge.. That's why guess work is also crucial at times !!
guessing abilities T_T
Why do you announce results even though it is before systests xD?
hello, how can i improve to solve the problems? im new here
Try to solve the problems from the easiest one.
Thanks, I'll do that, I'll start with the 1000
in d we have to guess two numbers a[n-2],a[n](for 1 based insex) still i can't guess skill issue, LOL,and meanwhile in C i guess up to 500*500 correct no's
constructiveforces
C was the worst problem I have ever solved.
where tutorials?
plz make a contest where shit newbies like me can ALSO SOLVE SOME PROBLEMS,,,,LIKE WTH WAS A?
Fun fact: the solution of 1693D - Decinc Dividing gets Wrong answer on test 2 in 2101D - Mani and Segments.
Can you provide a case where avoiding
3,1,4,2
3,4,1,2
2,1,4,3
2,4,1,3
wrong?
UPD( fails on 2 5 3 1 4)
in fact 2 5 1 4 is 2 4 1 3, and you can avoid it, see 319312314.
i was SOO distracted i +1 A and B :sob: but in the end i think i did alright, great contest!
In B of div1 and D of div2 why is my submission failing, i try to get the smallest number to front, and then recursively keep making the array smaller and smaller until no more operations are possible, I want to know my mistake before seeing the editorials answer.
it seems you can still sort last remaining 3 positions if you do some swaps before doing the whole process you are doing.
how come we have winner list before system tests have finished ?
I wrote 3.24KiB for 1C :(
How did you solve this problem?
rainboy orz
Congratulations Radewoosh for AKing + Winning !!!
I like the problems, quality is standard div1 level.
One of the best CF problemsets I've seen in a while, huge congrats to the authors! <3
D глина, еле заслал
I was able to understand exactly what I needed to do in the first 4 questions to get A correct ans but sadly, I was only able to implement the first 2.
D https://judge.yosupo.jp/problem/static_range_lis_query sorry
Thanks for sharing, I forgot that this existed. :P
How to D
bubble sort maybe.
I wouldn't. You do eventually have to sort, but the constraints suggested a complexity of O(n log n). So I just pulled out my trusty mergesort where I needed it.
Answer will be sorted arr(resp of odd and even position) just need one extra swap for odd number of inverions
Ama go volunteer back in the army cause WTF is the solution for Div 1 C lol?
What is the intended time complexity for Div1E? I implemented $$$O(N \sqrt{N} \log{N})$$$ solution with sqrt decomposition but narrowly TLE, so I think that there may be more efficient solution.
I had $$$O(N\log^3N)$$$ running in 3374ms. Basically running https://judge.yosupo.jp/problem/vertex_get_range_contour_add_on_tree $$$O(\log N)$$$ times (though I was somewhat slow since I wasn't familiar with the solution code).
Also, it shouldn't be hard to remove a log factor since in this problem all adds are happening before gets, and the adds are on prefixes only.
319295559
I was able to solve problem B but not A.. Can someone please help with problem A!!
Think of this, say n is not divisible by p, now the sum of the entire grid would be (n/p)*q plus the sum of remaining n%p elements. You can clearly see we can achieve any sum of n is not divisible by p by having desired values of last n%p elements . Now take the case when n is completely divisible by p, here we don't have a choice, is (n/p)*q doesn't add up to m we cannot possible get this sum, as here we don't have the freedome to assign values to last n%p elements.
Notice that the constraint on the segment sum essentially means that the values loop throughout the array over a period of p.
Now, if n is not divisible by p, there will be only part of that loop (segment) at the end, which can carry the total sum to m, and the rest of the segment can compensate and bring the segment sum to q, so it's always YES. If n is divisible by p, then you don't have that extra flexibility, and the segment sum times number of segments must match the total sum. In other words, YES if q*(n/p)=m and NO otherwise.
My first time reaching the 1st page of the final standings omg
I'm so happy
I don't mean to be mean but how does a guy with best perf top 1700 do ABCDF? There's no way you didn't use AI / do account sharing
ABCD are all not really hard and at least 1000 participants worked them out, right?
As for F, I don't think AI is so boring to make this silly solution actually, this is just simple binary search. If you want more details what have I thought:
First, I found that all the cute subarrays has partial order under the inclusion relation. So in this case, one may notice that it's only needed to search all the maximal cute subarrays, using two-pointers.
Second, still the property of partial order, you can use binary search to find the maximum right border when fixing the left border.
After finding these 2 properties, I tried binary search. After passed the examples, I tried $$$n = 200'000$$$ random shuffled permutation (you may notice that there's a comment in
main()that usedfreopen). But it resulted TLE. All the next things I did is just try something that may speed up, like recording low high array to speed up the inserting process, still using binary search for the deletion process. And it just happened that it worked, I can't even believing why it worked lolCongrats, you are insane! GM when?
I'll try my best! Thank you \('w')/
You can see 319236013 clearly states
// Extra vector added to reduce plagiarism.Ban shubh1211
1C is much harder than 1D and 1F. that makes me have no time to solve 1F
I finished debugging my E one minute post-contest and it passed... :(
Same here... :(
Nice round over all!
Thanks to the all the staff who helps to hold this round.
Guessforces on C, went with pure instinct and it worked :)
Is ternary search nlog^2n is one of the intended solutions for 1C? Then why the harsh time limit, I'm so tilted rn
I also use the same time complexity in this. I use set and run 1140ms main test
Eyyy!! +60 for solving 3/6! Yeah!
Read 1D as 1693D, worked on it for 1.5h, and finally wrote the full code, until realizing I've read it wrong.
I totally forgot that, three years ago, I solved it during contest!!
Furthermore, my today solution, and the one that I wrote three years ago, are completely different!!!
I really liked the contest! Even if I wasn't able to finish my solution for Problem D (I'm still somewhat slow programming, and I had to look for the code to compute the sign of a permutation after contest) I found it very interesting. Probably the type of contest I would like to see more as a math student haha.
first time I've seen a nice constructive problem :O , It was worth timespending
BTW orz Radewoosh rainboy
I have used an ai tool to generate code for printing spiral matrix for div2-C. I am not sure if it's within the guidelines. I got the logic by myself then i used an ai tool to write the code for spiral matrix.
Its mentioned here that
If you're unsure whether a particular AI use violates the rules, please consult the competition organizers.I want to know if this use is permitted or not.
It is scrictly forbidden to use AI during a live contest for any purpose,all accounts for plagiarism
if you check the link, its mentioned that
Using AI to generate simple boilerplate code (e.g., input/output functions) is allowed.Using them to generate the core logic or algorithms for solving problems is not permitted., which is your case.tbf im surprised its even allowed at all, even if its for "minor code suggestions"
Input/output functions. As if one couldn't have them prepared before the round.
That probably counts as cheating. There is a world of difference between boilerplate code for IO (that just gets the input in a manageable form for the algorithm) than using it for the implementation of the algorithm itself.
Seeing at you submissions, it took you 30min to submit your first wrong program for C, after which you used AI (as you said in your comment) to get a correct implementation. Seeing that you found the implementation of your solution a challenge, you cannot argue that it's just meaningless boilerplate code. This is Competitive Programming, not Competitive Thinking: even though it's important to find the correct algorithm(s), finding a way of implementing them in a concise and fast way is part of the challenge. Using AI for that is, thus, cheating.
@janelle_m my first WA was not due to a
incorrect implementationas you have said, it was because of incorrect logic. I intended to print a completely different matrix. After WA, i found the issue in my logic and then corrected it. For evenn, i dont know why but i thought the index which will be present in maximum sub-matrix will be the corner one and sadly it passed for n =2.Q. Is it ok to search for method to find gcd(a, b) during live contests?
if yes then me using ai to write me a code of spiral matrix with 0 at the center should not be considered as cheating. Printing a spiral matrix is not a new thing, and code for this is publicly available. Anyways lets wait for the judgement of cheat detection thing.
Although i am still not sure if its actually allowed or not, but its safe to not use AI in competition for anything, cause you dont know where the line is.
Here is a solution for Div1C / Div2E, which uses trenary search (seems to be alternative approach to what most people used).
To find optimal k, ternary search can be used. Submission: https://mirror.codeforces.com/contest/2102/submission/319299542
Can someone help me why the solution which i submitted using Set fails but one which i submitted using priority queue passes. Set — https://mirror.codeforces.com/contest/2101/submission/319668536 PQ — https://mirror.codeforces.com/contest/2101/submission/319668295
Shouldn't both take similar timings as both have TC of O(logN).
I think it's expected behavior. My solution with set got 3781 ms result and the one with priority queues — 1092 ms. I see you use 2 sets (I used 1), so it will probably need something around 7500 ms. Priority queue is much faster than a set, it's a known fact, explained by how the elements are stored (vector versus a tree, where adding nodes require frequent memory allocation). Instead of using 2 sets you can use one: remove the "back" set. Instead of
use
etc. It still gets TL (on test 9 instead of 7). I managed to get AC with another optimization: golden section for ternary search. It passed in 3200 ms: https://mirror.codeforces.com/contest/2101/submission/319685824
So, there is no bug in your solution with set. Red black tree is just generally much slower than a heap.
Just found a Random hustler the-raja who gave todays contest just for fun ,and above that he proudly boasts about in on his linkedin ,when I asked him about his apporach in D ,he replied with an AI generated response . The guy's post link on linkedin
hey_twin
damn bro
damn
Bashed 1D with sqrt + bitset: 319301576. I had like 6 bugs, so I didn't make it to the time...
Hope you reach GM soon bhai
Thanks, I hope it too...
can you please just correct me if I am wrong , I love solving math and number theory problems ,but I suck at implementation problems like dp and SegTree , should I start studying topic wise ,or rather just give myself time to solve more higher rated Dp problems
I have $$$O(n)$$$ solution for D1.
Observation: if $$$p[1...n]$$$ is cute, then $$$p[1...{n-1}]$$$ and $$$p[2...n]$$$ are cute as well. So, we can use two-pointers to calculate intervals $$$(i, r_i)$$$, where $$$(i, r_i)$$$ is the longest cute subarray starting at $$$i$$$.
To do so, we have to maintain LIS and LDS in deque (to simulate two pointers), but notice that $$$(i, r_i)$$$ is cute, meaning that LIS + LDS $$$ = r_i - i + 2$$$ (this fact simplifies problem).
Since, we only considering cute subarrays adding $$$p_j$$$ to the back of the deque is easy, since LIS or LDS must extend by element $$$p_j$$$, and non-extending longest subsequence can only change its last element.
Deleting $$$p_i$$$ from the front of the deque is a bit harder, since it is possible for $$$p_i$$$ to be a beginning for both LIS and LDS. In this case, we can proof that after erasing $$$p_i$$$ we always can extend LIS/LDS in the front by the first element of LDS/LIS.
And the last case occurs when LIS = 1 or LDS = 1 (but not at the same time), in this situation the one having single element must change it to the last element of the other one.
My solution: 319304301
I have a different $$$O(n)$$$ solution for 2101D - Mani and Segments.
All this is possible using next greater element and prefix / suffix min / max. My submission (319283002) is $$$O(n \log n)$$$ because I calculate next greater element with a set, but it can be optimized to $$$O(n)$$$ with a stack.
It seems like there is quite a large variance in judging time that can happen; during pretests my solution for C passed in 3840 ms, in system testing it got TLE on test 9, right after system testing finished i submitted it 2 more times and it got TLE on test 9 both times, now i submitted it again and it got AC in 3718 ms. A variance of 50 ms is something I'd expect but I had no idea there could be a difference of over 300 ms...
It happened to me so. My solution to div1E(https://mirror.codeforces.com/contest/2101/submission/319279543) got TLE on pretest 97(after waiting 10mins..), but when I submitted exactly same code after systest(https://mirror.codeforces.com/contest/2101/submission/319301076), it runs in 5656ms.
MFW Problem D
OMG same!
This is for 1D or 2D? I don't see how this could be related to 2D.
Div $$$2$$$D. Just implementation of selection sort, which is $$$O(N^2)$$$
But then you throw in TREAP, and wooosh, magic magic $$$O(N \cdot log(N))$$$
For 1B, I forgot to use
long longs for counting inversions but it still ACed because overflow preserves parity :)I think several people still got WA because of this. I think they use %2 directly so for example -1 and 1 will get different result, thus they got WA.
Using
if (inversions % 2)should still AC though (since both 1 and -1 will result in true)Got wrong answer on Div1A due to wrong Spiral Printing Code on GeeksForGeeks. Somehow it prints the correct matrix for n = 2 and 3 (the sample test cases), and gives ridiculous output on n = 4 :(
maybe don't rely on others' code to solve contest problems :D
I mean it is allowed to do that. Also it was not trivial to implement so I thought, might as well take it from the internet
I found printing the spiral backwards, starting from one of the corners, somewhat easier.
Here are some of the top cheaters : [2ky], [LuOH3_] . Know more??? Add them to the list — justice awaits...
Yeah... @2ky, @LuOH3_
Hey what are you talking about here?
I'm talking about you. Just look at your rating graph — How is it even possible to reach Specialist in only 2 contests? And You reached Specialist in just 2 contests and solved only 11 problems in total ???
Did my code look AI generated or what?
Okay Well. But How it is possible being a Specialist in only 2 contests..??
I don't want to be rude but... Practice hard and get better I think? I can just be lucky in this case. Getting first place is unexpected for me.
I think you should just get gud, instead of wrongly accusing others for cheating.
Who knows, you might be the cheater here.
From today for me if CF-A==250 then it's a signal
When is editorial coming out
For div1C, is $$$O(nlog^2n)$$$ not allowed? I realized we can do it in $$$O(nlogn)$$$, but this $$$O(nlog^2n)$$$ submission passes in 4.5s while the time limit was set to 4s.
use scanf or fast IO may be helpful. I passed it with $$$\log^2$$$ in 3.8s.
My $$$\mathcal{O}(n\log^2{n})$$$ solution with
std::set+ binary search (1.1 s): 319296499Using DSU instead of
std::set(125 ms): 319298390I see, basically my code calls the function twice in the binary search. Single call passes within 4s. Thanks
When solutions?
solution plz ToT
Spent almost two hour to IMPLEMENT Div2 C... this recall me some interview questions
Dear Codeforces, Hello, I am jitesh66, and my solution (ID: 319249391) for problem 2102C has been flagged for similarity with another user's submission.
I want to firmly state that this is completely my original work. The logic used — spiral traversal of a 2D array — is a well-known and standard technique. It's quite natural for different participants to arrive at similar-looking implementations when solving such problems, especially when the approach is straightforward and commonly used.
It is deeply concerning that such a basic and commonly taught method has been flagged as a violation. Just because two people wrote similar code for a standard idea doesn’t mean either one copied the other. How can it be assumed that I didn’t write my own code, especially when there’s no evidence of any unfair activity from my side? Even the editorial suggests spiral traversal, and I independently figured out and coded the logic on my own.
I did not collaborate, copy, or leak any part of my code. If similarities exist, they stem from the nature of the problem and the algorithm required to solve it — not from any violation.
I request a fair and thorough review of this case. Penalizing users for applying standard techniques undermines the spirit of the competition.
Thank you.
All three of my problems for this contest have been skipped. I literally handwrote all the code and thought about the logic, investing a lot of time in it. My multiple solutions were incorrect on pretest 2, which I further debugged myself. Why were these solutions skipped? It undermines the effort I put in, and in return, I am told I copied someone else's code. Moreover, I received a notification for my problem C, but all of my codes have been skipped. It makes sense that, given the nature of problem C, implementing a spiral matrix can turn out to be a standard code; hence, it can be flagged, which is again incorrect but somewhat understandable. However, skipping the other two problems too literally makes no sense to me; that is a really wrong decision.
Kindly look into the matter. I have genuinely tried to perform well, and I don't want to be flagged as a user for no reason.
Hello Codeforces team, I recently received a notification that my solution to problem 2102C (submission ID: 319280419, handle: samuka7abrr) was flagged for similarity to others. I want to sincerely apologize. I did not copy or share my code with anyone, but I now realize that discussing the solution logic with friends during the contest was a mistake. At the time, I didn’t fully understand that even this kind of discussion goes against the rules. I deeply respect the Codeforces platform and its community, and I truly regret this lapse in judgment. I’ve learned from this experience and will make sure it never happens again. I kindly ask for your understanding in reviewing my case. Thank you for your time and for maintaining the integrity of the contests.
— samuka7abrr
Just to clarify, the friend I mentioned was not a participant in this round and did not make any submission. His Codeforces handle is: JoaoGenaro11. We only discussed the idea briefly, and no code was shared in any form. I now fully understand that even that level of interaction during a contest is discouraged, and I’ll make sure to strictly follow the rules from now on. Thank you again for your attention.
hey i am kind of new in cf so can you tell me if this is contest violation, i used the spiral traversal logic which is kind of well known from gfg and got flagged for that, can i not use any online source in contests. I don't know if you can call that as cheating, i just wanna know then i will refrain from using online sources as well.
also i got -ve rating change in this contest will this change, if i have skipped contest
Dear Codeforces team,
I have received a system message indicating that my solution (ID: 319262165 for Problem 2102C) significantly coincides with many others. I would like to respectfully clarify that I did not engage in any form of malpractice, code sharing, or plagiarism during the contest.
I used my own knowledge and followed a standard approach to solve the problem. Any similarity might be due to common logic or standard patterns used by many participants for this type of problem.
To be fully transparent, I occasionally use OneCompiler (an online compiler) to test and debug my code privately. It is visible in my browser history, but I want to emphasize that it was used solely for checking my own logic — not for accessing or sharing any external code.
Additionally, one of my consistent coding habits is using English-Hindi mixed variable names in my solutions. This is a personal convention that reflects my individual style and supports the fact that I wrote the code myself.
To further support my case, here are screenshots of my browser history during the contest, showing I was active only on Codeforces and OneCompiler: - Screenshot 1 - Screenshot 2
Handle: Manan_Joshi
Solution ID: 319262165
I kindly request you to review my case. I deeply value the Codeforces community and its integrity, and I assure you I participated fairly and honestly.
Thank you for your time and understanding.
Three legendary coder for all time...
Happy
Dear MikeMirzayanov and Codeforces Team,
I am writing to respectfully appeal the plagiarism verdict associated with my submission for 2102C - Mex in the Grid . My submission ID is 319271152.
I am writing to respectfully and sincerely assert that my submission in question is entirely my own independent work. I fully support Codeforces’ commitment to fair play and understand the importance of protecting the integrity of competitive programming. However, I genuinely believe that the similarity detection in this case has resulted in a misunderstanding, and I kindly request a careful review of my situation.
The approach I used spiral traversal of a 2D matrix is a well-known, classical algorithmic pattern. It is extensively discussed in programming lectures, tutorials, and competitive programming problem sets. After constructing the matrix in a spiral order, I simply reversed the values to ensure the grid values were arranged from n^2-1 down to 0, aiming to maximize the sum of MEX values across all subgrids . Given the structure of this particular problem and the constraints provided, this technique naturally suggests itself as a logical and efficient solution path. It is entirely reasonable that multiple participants, independently working through the problem under contest pressure, might arrive at similar solutions when employing a widely used technique.
I want to emphasize, with utmost honesty, that I developed my solution independently during the contest. At no point did I copy, share, or receive code from anyone. I did not use any public or external IDEs, and I maintained the contest's spirit of integrity throughout. To further support this, I would like to highlight my submission timeline:
Problem B submitted at 20:35 (UTC+5.5)
Problem C submitted at 21:36 (UTC+5.5)
The one-hour gap clearly reflects the time and effort I invested in understanding and crafting the logic for Problem C on my own. This was not a hurried or opportunistic submission but the result of genuine, independent work. I humbly ask the team to consider the broader context — that similarity in structure does not imply dishonesty when dealing with a canonical algorithm.
I sincerely hope the team can re-examine this case with understanding and reinstate my submission. Thank you very much for your time, fairness, and consideration.
With respect,
SANDIPAN_KUNDU
Dear Codeforces, Hello, I am deepiit.gupta, and my solution (ID: 319251371) for problem 2102C has been flagged for similarity with another user's submission.
I want to firmly state that this is completely my original work. The logic used — spiral traversal of a 2D array — is a well-known and standard technique which also has a question on leetcode (problem — 59) . It's quite natural for different participants to arrive at similar-looking implementations when solving such problems, especially when the approach is straightforward and commonly used.
I did not collaborate, copy, or leak any part of my code. If similarities exist, they stem from the nature of the problem and the algorithm required to solve it — not from any violation.
Regarding Plagiarism Flag on Submission 319255450 (Handle: Athk_0312)
Hi Codeforces Team,
I'm writing about the plagiarism verdict on my submission 319255450 for Problem C from Round 1024 (Div. 2). My handle is Athk_0312.
I want to clarify that I didn’t copy anyone’s code or cheat in any way during the contest. The solution just involved filling the matrix in spiral order, which is a very common pattern. In fact, it's the same approach used in well-known problems like Leetcode 59 (Spiral Matrix II), so it's quite natural for different people to come up with very similar-looking code.
Since the logic is straightforward and widely known, it's likely that my code ended up looking similar to others. But I can assure you it was completely my own work.
Regarding Plagiarism Flag on Submission 319274770 (Handle: agrawalheyramb)
Hello Codeforces team and reviewers,
I am Heyramb Agrawal (handle — agrawalheyramb), and my submisssion for Probblem C (Mex in the grid) is flagged for plagerism. I firmly believe that this is false positive, as I independently wrote the solution on my own. This problem can be easily solved using the standard spiral traversal of matrix. In fact, I had previously solved the spiral-matrix problem on LeetCode, which clearly predates the contest.
I am also attaching link and screenshot of my previous LeetCode solution of spiral matrix traversal. Link to Leetcode problem
I humbly request the codeforces team to reconsider this flag.
[user:agrawalheyramb][submission:319274770][problem:C Mex in the grid][contest:2102]
Subject: Clarification Regarding Solution 319263520 for Problem 2102C
Dear Codeforces Team,
I hope this message finds you well. I recently received a notice regarding my submission (ID: 319263520) for problem 2102C, which is said to significantly coincide with another solution.
I would like to clarify that I did not copy any code. The approach I used is a well-known and standard method for filling a spiral matrix, which is also commonly used in LeetCode Problem 59 (“Spiral Matrix II”). Given the nature of the problem, it is likely that multiple independent implementations may appear similar in structure and logic.
I assure you that my solution was written independently. I kindly request you to reconsider the plagiarism flag, taking into account that the approach is based on a widely known algorithm.
Thank you for your time and understanding.
My Handle : Suryxnshu
By Recognizing the pattern for the problem 2102C in the div 2 round for the above mentioned contest, I found that the problem can be solved using the the concept of spiral traversal of a matrix. Being a student, I have just learned this algorithm from a very renowned educator Striver, I am a regular student of his DSA A2Z course, When I saw the problem 2102C, and found that I can use the code of spiral traversal of a matrix. I just wrote down that similar code, which I have already submitted on LeetCode for the problem: _https://leetcode.com/problems/spiral-matrix/description/_ on 29th of January of this year, much before the start of this contest, also the same code has been discussed in a YouTube video(_https://youtu.be/3Zv-s9UUrFM?si=Brj83eeQyN5L8buC_), and its code is also available on a public website (_https://takeuforward.org/data-structure/spiral-traversal-of-matrix/_), I could only say that whatever I have done can also be done by someone's else, I would request the higher authorities, to please look into the matter and understand this is a coincidence not a rule violation, some other unknown individual can also submit that code as it is publicly available and its video tutorial is also there.
My LeetCode solution:https://leetcode.com/problems/spiral-matrix/submissions/1523615991/
2102C][CONTEST:2102][SUBMISSION:319272738 - Mex in the Grid
...
three legendary coder in the world for all time...!
Subject: Clarification on Solution 319260324 for Problem 2102C
Dear Codeforces Team,
I hope this message finds you well. I recently received a notice regarding my submission (ID: 319260324) for problem 2102C, which is said to significantly coincide with another solution.
Regarding this ,I would like to clarify that I did not copy any code. After i got the idea that we should take the elements in a spiral, I took that code template from GFG.. This is the reference — _ https://www.geeksforgeeks.org/print-a-given-matrix-in-spiral-form/_ i just modified a bit and submitted this. The approach I used is a well-known and standard method for filling a spiral matrix, which is also commonly used in LeetCode Problem (I practiced it while solving Takeyouforward sheet).
I assure you that my solution was written independently. I kindly request you to reconsider the plagiarism flag, taking into account that the approach is based on a widely known algorithm.
Thank you for your time and understanding.
My Handle : "_Hadwik_"
eren__ can you share the checker code for d1A, Mex in the Grid
Read the function f.
thanks! having a check for more than 1 occurence before counting helps
Dear Codeforces Team,
I recently received a message stating that my solution for problem 2102C (submission ID: 319263905) was flagged due to significant similarity with other users' submissions. I would like to respectfully clarify that I did not copy or share my code with anyone.
The problem in question requires filling a matrix in a spiral order and then transforming the values in a simple manner. This is a classic and standard approach used widely in competitive programming. As a result, many solutions will naturally look similar — especially in logic and structure — even if independently written. The use of standard spiral traversal with four boundaries (top, bottom, left, right) and directional loops is the most straightforward and efficient method to solve such problems.
My code was written entirely on my own. I understand the rules against plagiarism and take them seriously. I kindly request that you review my explanation and reconsider any penalties.
Thank you for your time and understanding.
Sincerely, Pranav_006
https://leetcode.com/problems/spiral-matrix/submissions/1429584542
This shows that I had already implemented this approach prior to this contest, and I merely reused that same familiar pattern in the Codeforces round.
I understand and respect the importance of fair play in competitive programming and assure you that I have followed the rules diligently. I kindly request that you review this context and reconsider any penalty.
Thank you very much for your time and understanding.
Shoo please look into this, this has resulted in a drop in my ratings which I worked very hard for
idk why is codeforces not conducting any contests further, i have been checking the contests page daily, but i do not see any further contests.
Dear contest organizers, I submitted one entry for Question 1, which failed a test case 1 , resulting in a rating decrease. Could you please review this matter?
Dear Codeforces, Hello, I am BitPopper, and my solution 319243570 for problem 2102C has been flagged for similarity with another user's submission.
This is a simple problem and we just needed to print the spiral matrix from inward to outwar. It is a standard problem to print the matrix in spiral form from outward to inward which is availiable on GFG and then we just needed to invert those by subtracting from n^2 which is a standard approach.I also created my own totalMex function to test out my earlier approach answer (it was based on sorting by manhattan distance) which gave wrong answer and then i went with spiral one. You can also see in my comments i have tested the test cases with that function.
I did not use ai or anything, you can also see i got wrong on A which was due to a missed =, as well as i solved D also. Please look into this
Thank you.
Shoo Please look into this, as i provide the source also when i use the ones on internet as can be seen in submission D. :(