Hi everyone!
ne_justlm, itz_pabloo and I would like to see you as participants of Codeforces Round 1006 (Div. 3), which starts at Feb/25/2025 17:35 (Moscow time).
The round will be held according to the rules of educational rounds. Thus, during the round, tasks will be tested on preliminary tests, and after the round there will be a 12-hour open hacking phase (we really hope that not too many solutions will fall during it).

How the next announcement is made:
- this is where copy-paste starts,
here is your text, icpc rules, etc.
- this is where copy-paste ends.
You will have 2 hours and 15 minutes to solve 7 problems. The penalty for an incorrect submission will be 10 minutes.
We remind you, that only reliable participants of the third division will be included in the official results table. As it is written on the link — this is a necessary measure to combat unsportsmanlike behavior. To qualify as a "trusted" member of the third division, you must:
- take part in at least two rated rounds (and solve at least one problem in each of them),
- don't have a point of 1900 or higher in the rating.
Regardless of whether you are a trusted participant of the third division or not, if your rating is less than 1600 (or you are a newcomer/unrated), you may choose to participate rated or unrated.
We would like to thank MikeMirzayanov for the Codeforces and Polygon platforms, and Vladosiya for incredibly cool coordination of round preparation.
As well thank you very much we would like to say to Kirill_Maglysh for his huge help in creating this round.
Also thanks for our testers:
tch1cherin, WLZ for red testing.
Egorsa, shadow9236, cry, alexsushin, Sokol080808 for honey testing.
Ianis, kaferius_cf, NerfThis, ukhalikshina, umezo, Escapisst, hump-and-bump, Kosya for such a familiar and close, water testing.
tih-a, mkshh, Pozercpp, Kraska, radodododo, giorgi_pkhaladze and I hope the universe will be merciful to you.
myav, sujan_roy24, t.muksunov, imtheonly1, DevUt for pleasant natural testing.
UPD: EDITORIAL ON CF Editorial








yayyy first comment! (only wish that the contest was over the weekend :( )
Watch me win this contest ...
well this aged well
Excited! hope for +pos delta.
I hope for +pos delta too!
I only AC six problems(ABCDEF)...T_T
How C did a-f excluding c
At least you have a suitable array {$$$x$$$, 0, ..., 0}. Consider the definition of MEX that means the minimum nonnegative integer not contained in your array, and you'll get a greedy idea: use 0, 1, 2... to replace those 0 in the origin array, until a number making their bitwise OR sum not equal to $$$x$$$. An interesting detail is that $$$x$$$ can also be replaced, and the sample shows it.
Feel free to continue the discussion if you have any questions!
As a tester I can say that I am a tester
as an author i can confirm that he can say that he is a tester
thank you bro
As a Codeforces user I can say I am a jerk
Nice contest sir
Other authors deserve the chance too
As a tester I tested the first Phystech Lyceum (our school) round. I found some problems interesting, so I recommend participating!
My first time testing a contest. Problems are interesting. Please participate.
As a tester, I have a proof that upvoting this comment will lead to positive delta. But the proof is too long to fit the margin.
We got FLT memes before GTA VI :(
Hoping for +del and wishing everyone +del
As a tester I can say that it was my first testing and all problems were interesting.
Good luck and positive delta to everyone!
time to recycle this meme lol
I hope I dont fumble this contest and reach expert
all the best
good luck
gl bro
same
7 problèmes à résoudre en 2h15, avec une pénalité de 10 minutes pour chaque erreur. Si t’as déjà rêvé de rager devant un bug à la dernière seconde, c’est le moment parfait.
Mon objectif ? Réussir au moins un problème, histoire de ne pas pleurer en relisant mon code après coup. Bonus si j'évite de tomber dans un piège bien vicieux.
Que le karma des AC soit avec moi."
hhhhh, enfin quelqu’un qui comprend la vraie douleur du competitive programming ! Entre les erreurs bêtes, les tests cachés et les cas tordus, ce round promet d’être un grand moment de réflexion… ou de désespoir.
Mais bon, tant qu’on ne finit pas avec un score de zéro, c’est une victoire. Bonne chance, que ton code compile du premier coup et que les WA t’oublient !
Recently, the use of reasoning LLM models has impacted CF rounds, as more submissions are getting AC than usual due to increased AI-assisted problem-solving. This raises concerns about rating inflation and the integrity of contests. Implementing defensive measures against it is necessary, but not an easy task. Let's see how things unfold.
Seems like the use of LLMs has impacted comments as well. Implementing defensive measures against it is necessary, but not an easy task. Let's see how things unfold.
fun fact :
the photo will change depending on what language you are choosing in cf
it would be cool if we did div 3 and div 4 more often for beginners, including me
I have a question. Do we get paid for preparing contests on Codeforces? If so, then how much for each division?
Yes, you get money for creating rounds on codeforce. Unfortunately, I don’t know how much they pay for creating rounds
no u don't u get only for div1/2 round
Tester categorisation is really great and funny.
I hope ne_justlm added a promblem about stari_bog and gamblers (I hope google translate translated the text correctly)
he added very good problem about kinder pingui
As friend of all creators, I am sad cuz there is no komaru in the photo :(((
As a former groupmate of some authors I can say there's no Om Nom unfortunately.
hopefully i touch Lever in this contest :)
please dont
bro you know you can't delete that right?
yeah im aware
your bitset blog wasn’t just any blog, it was a revelation, a spark that ignited a movement, making people see the sheer elegance of bitset in ways they never had before. I wasn’t just inspired, I was transformed. Your words didn’t just optimize my code, they rewired my perspective, making me realize how much bitset had given me, not just in refining my craft but in fortifying my very being.
Confidence, clarity, even a sense of belonging, the things one might seek in a partner, I found in bitset. It wasn’t just an STL structure. It was everything, and your blog made me discover these things, so, Lever, thank you.
are you two edating or smth
no, were not
i'd date him tho
i hope everyone get positive delta
I accidentally registered unrated. Can I undo it and register again rated?
Click on the number of registrations
I wonder if i can reach pupil this contest
I'm gonna absolutely destroy this context. Just wrote myself a new template file.
hope to get +1 this time
I hope to get +5 this time
yay!
I wish I could control my dopamine not to participate in these div-3/div4 contests and dropping my rating by a big amount.
Us! But today I'll
get + delta and reach $$$Speacialist$$$
I wish all the best to all the contestants either you are newcomer or professional hope the rate of all of you get increased super high hope you learn something useful hope you dont get wrong answers or anyother problems hope you get the accepted easily <3
Longest problem title I've ever seen on Codeforces.
Div3 is cooked. GPT has killed all questions.
so what?
SO you used GPT?
Bruh seriously, just stop complaining about GPT under every single Div3/Div4 post. The staff knows about it. Everybody knows about it. Just let the staff do their job, they are already trying very hard to enforce the rules.
I agree with you but the today's problem F was not even gpt problem it was a google problem what's the point of keeping suh problem
Biggest Negative Delta incoming! T_T
It's nothing, but if you want to get higher rating, I think study more algorithms is better than participating in CF contests.
Can you also share resources from where i can practice
Thank you ♥
I think the courses on AcWing is good (if you are Chinese, because the teacher speaks Chinese and the videos do not have subtitles). Also, there are plenty of sources on the Internet, you can just search for 'Algorithms' and watch the videos carefully and you will make a progress!!
ezzzzzzzz
problem F 's main idea
Never heard of it, but I like triangles
there is a simple trick to compute whether ncr is even or odd you can find it in usaco guide combinatorics section link : https://usaco.guide/problems/cses-2419-xor-pyramid/solution
Incredible contest! Maybe on the easier side but the problems had a very nice pace and a slow ramp up in difficulty. Maybe one of my favorite contests ever.
What is the pattern in F?
for me it's triangles + recursive
Amazing! someone else have the same idea I discovered that many contestants has just find a pattern without even thinking and it is AC. I hope not to see pattern problems it is just a waste of time and let others to just solve it.
define "without even thinking"
They just see a pattern or use any online pattern finder without knowing why this works. I don't mean you I mean who was trying bitwise operators until they AC with (i & (n-1)) == i.
I see,
never occurred to me to use online pattern finder.
Here
This
how did you arrive at that?
I figured that the required value is basically pascal triangle which is also
nCr. (in this casen-1CrasnCrhasN + 1terms). Then I found that determining whethernCris odd/even is a well known problem: https://math.stackexchange.com/questions/11002/cn-p-even-or-oddBut wasted so much time trying to come with a generation matrix that is typical of such recurrence problems.
Thanks. Nice observation...
notice how pascal triangle and magic triangle are related odd==K and even==0 ~~~~~
~~~~~
~~~~~
kk...kk->k0...00k and those 2 ks "initialize" 2 new triangles https://ibb.co/Cpc13fdL a row has a form of R + 00...00 + R, where R is the corresponding row in the smaller triangle, so its possible to solve this problem recursively
little secret: Diff picture for Eng and Rus post
Stop making problems with so many math calculations, I could've easily solved G if I didn't have overflow but ofc i couldn't find it coz it's so much writing to do
Fun one, I got all but the last one. Thought I had the math but didn't have it 100% and didn't have the time. Hope everyone did well.
E is so tricky, still couldn't figure out why my solution not working.
The problem is a roundabout way of saying number of pairs where Manhattan distance is the same as regular distance. Or in other words, for every pair of staves that share one X or Y coordinate.
For a given x or y, the number of pairs is sum from 0 to (number of staves on that X/Y minus 1). For instance, if there's 2 staves with x = 3, then on x = 3 there's 1 pair (sum from 1 to 1 is 1). If there were 6 staves, there'd be 1 + 2 + 3 + 4 + 5 = 15 pairs. You see?
Very easy to make the needed amount of pairs with 500 staves because of how it grows. Sum of all numbers 1 to n is about half n squared, 500 squared is ginormous so 500 is more than enough staves to fit the problem requirements no matter what level spell.
Trick is to just make sure you keep them separate. Pick a y coordinate, stack staves on that row going up by 1 x every time until adding an extra one would take you over number of pairs. Then move up a row (change y), but don't reset x to not add any extra pairs. This solution makes all pairs have the same row, NEVER the same column so no two staves have the same x. (In my actual solution I reverse X and Y here but same thing). Works no matter what, just have to iterate through staves and move up by one, simple addition.
how to C?
Add numbers 0 to n until their bitwise OR contains a bit that is not contained in X, then add X in the remaining positions. If the total bitwise OR in the end is not equal to X replace last number with X
and after doing this if bitwise or of array != x, replace last element with x
yep I added that
try to add current mex till you cant( means if((mex|x)!=x)) break here for last element check if adding mex will make OR ==x if not just add X in the end else add mex
Hint: be greedy to maximize mex first. If failed, to get the k, assign the last element = k.
You need n-1 numbers that has same set bits as number x. And after getting those n-1 numbers, the last number will be a number which makes total OR value equals to x. So keep track of made value and required value. To maximize the MEX value take numbers starting from 0, 1, ... and so on, untill for some number some bits are on where x has off bits.
Nice contest! I liked problem F
Is this round easier than usual? I think it is my first time to solve E (forget about not solving D)
E<B,C,D for me
Fumbled on C again. I've over complicated stuffs :(
should have tried D that was easier
Yeah I analyze the problem after 10 min, feels like a straight brute force to me.
AC in 25 minutes total. Indeed easier :(
The relief after finally solving E! (next time will solve in time haha) Didn't quite get D, I assumed it's something related to segment tree so skipped. Any hints?
I thought so at first but look carefully at the constrains
in D , n<=2000 shifting left means you will take one element to the back and nothing else will change , no lets see how this will affect inversions all the elements that are bigger than lets X will add + inversions , all elements that are smaller than X will subtract inversions. so you just needed to check how numbers between ith element to jth element will affect inversion change. you can check my code
For D, the operation is basically shifting one element to the right some number of times. Every time it passes over a larger number the number of inversions INCREASES by 1, a smaller number causes it to decrease. Trick is the input size is actually small enough to just brute force it from there. So you just go through each index, count from one after til the end number of biggers and smallers. At any index here the minimized inversions is the number of smallers minus number of biggers. Keep track of max every time, O(n^2) answer fits the time constraints.
The reference in 2072E - Do You Love Your Hero and His Two-Hit Multi-Target Attacks? is craaaaazy
if i'm not wrong all the titles are references. thought i'm not weeb enough to remember all of them, they just sound like trash-mid anime titles.
Do You Love Your Mom and Her Two-Hit Multi-Target Attacks? this is F title
yes, it's this one
well most of them are just trashy isekai
author loves isekai
the mother is so suspicious
Worst contest of all time F was formula chat gpt free version without using reason model was able to figure it out. What's the point of keeping such problem.
If problem were made to solve by the gpt then keep good non adhoc problems. Most of the genuine contenstants would be absoutely fine with it.
The construction in the problem is very beautiful and the problem is very educational for newer contestants, which a div4-div3 problem should be.
The contest authors aren’t obligated to make problems un-chatgptable, they’re obligated to make fun and interesting problems for humans. F was actually super interesting even though I didn’t quite solve it. This was a great contest.
But author are oblige to make problems that are not available in the internet
Also If it would be non adhoc problem then also it would be fine to me
It is also solvable without a magic formula
I got failed in G just because of forgotting to mod :(.
F similar to https://cses.fi/problemset/task/2419
Yes, I had solved that question earlier so i reused my code from there :D
This was more like a Div. 4 round
i tried nlogn for F but TLE whats the solution?
Pascal's triangle + binomial coefficient parity
n*log(n) works, are you sure you have O(n*log(n))?
It seems to me that you go through all numbers from $$$2$$$ to $$$n$$$ and on every $$$i$$$-th iteration, you perform $$$O(2^{\lfloor{log(i)}\rfloor})$$$ iterations to form a new line. For example, to build lines $$$1$$$ thought $$$8$$$ you'll do around $$$1,2,2,4,4,4,4,8$$$ operations. So, eventually you'll do approximately $$$1^2+2^2+...+(2^{\lfloor{log(n)}\rfloor})^2$$$ operations, which sums up to ($$$x^2$$$ integral) $$$O(n^3)$$$ operations. Correct me if I'm wrong.
The integral gives an imprecise result as it assumes that all natural numbers in the series are present, not only the powers of $$$2$$$. If we only take them into account, the sum will never exceed $$$(n+1)^2$$$ so the complexity will be $$$O(n^2)$$$.
nvm my solution is not actually nlogn
you double your p every time i is a power of 2. so p is always at least i/2. the average i is n/2 so the average p is at least i/4. your time complexity is O(average p*n)=O(n*n/4)=O(n^2), not O(n log n)
I think 2072E - Do You Love Your Hero and His Two-Hit Multi-Target Attacks? refers to Do You Love Your Mom and His Two-Hit Multi-Target Attacks?, ans 2072G - I've Been Flipping Numbers for 300 Years and Calculated the Sum refers to I've Been Killing Slimes for 300 Years and Maxed Out My Level. Any other refernces?
You're on a right way!
I thought you calculated the time the bruteforce for this solution will take,
$$$ 10^{18} \div (365 \times 86400 \times 10^{8}) \approx 317 years $$$
2072F - Goodbye, Banker Life refers to Goodbye, Dragon Life. just a random anime we found, didn't even watch it lol
How can I approach Problem G? Any topic need to know to solve this problem?
Just SQRT idea btw
Try to find for those base's for which length of n in that base is 1 and 2. For others bruteforce. (Think why brute would work)
Racist contest... Cancelled for racism -_- (problem B moment)
real
Good contest! Nice problem set! Nice ad-hocs! Everything was cool just not the
What is wrong in my logic of E
p1,p2 calculated as highest p1*(p1-1) <= k , similar logic for finding p2.
Place p1 points along X axis and then place p2 points along Y axis starting from 1, i.e, (1,0) and (0,1) respectively. Now number of pairs = p1C2 + p2C2.
Now place remaining k-(p1C2 + p2C2) pairs as points itself in the 4th quadrant, so they contribute to k pairs. Is there any flaw in this or can someone give a mathematical proof for E
You're overthinking it. As a tip, you have max 500 staves, and you don't need to minimize the number of staves at all. Put all the staves on DIFFERENT x coordinates so they never share a column. For each staves on row R, the number of pairs is sum from 1 to (R — 1). So with 5 staves on y = 0, number of pairs is 1 + 2 + 3 + 4 = 10. Keep adding staves til adding one would take you over the necessary pairs, then move up a row to restart back to 0. Keep doing this until you have all the pairs. 500 staves is way more than enough to do this, and any X or Y works as long as you increment when necessary.
yep got your solution, I debugged my code by handling answer whenever it goes > 500, I thought my solution always gave ans < 500, wasn't able to come up with a formal proof of it during the contest.
So your solution gives the minimum number of points we need to have right coz mine doesn't do that, I just constructed it
How do I get within time limit for G? I tried using one equation for everything between n and k, then calculating digits of n in each base k and adding their worth with multiplication, division and mod to the result. I got correct answers but time limit on test 3. I thought this was a harmonic series or something?
Did you add n for all numbers between n and k individually or did you compress it into a single expression (n-k)*n mod m. Apart from that it should be nlogn. Not sure if I'm missing something
I did all bases above n and below k at once like you said. I'll check the tutorial and see if I coded something else wrong.
Wow what a contest approx. half of the first page standings people cheated.
hackersheela — Global Rank 3
Delwar — Global Rank 1
Beserker69 — Global Rank 4
and many more examples like these are there.
I think we need to review the way the questions are given because problem G just needs to give the questions to deepseek and AC
Can anyone help me in today's G
hints:
for which bases the representation will contain only 2 digits?
how can you find the answer when the representation contain only 2 digits?
for other representation, is there any bruteforce solution?
Sqrt stuff.
For k <= n, there are O(sqrt(n)) numbers k such that p is 3+ digits in base k.
For all 2-digit numbers, there are O(sqrt(n)) first digits.
There is a Chinese blog about F:https://www.cnblogs.com/zhaohaikun/p/17031713.html
F Involves crazy observation, But the biggest beauty about that question is that you can solve it by just finding this pattern and doing a recursion.
1
1 1
1 0 1
1 1 1 1
Image
Solution
You can trace the recursive pattern even further back to the single 1 in the first row.
ever since when there's so many people solving such hard problems every contest :'). I guess i'm lacking behind so much :(
how to become a tester? wanna test some prob first hand !!
I don't get it why my solution is failing on samples. The MEX of my output in test-8 is also 5 and the jury's MEX is also 5. So where am i going wrong then ?
307885645
You are printing too many things for test case 7.
Please go after cheaters in full swing, I can't believe this many solves on F of Div 3. How come does everybody know Lucas theorem, clearly evident use of ChatGPT/Deepseek AIs in contest.
exactly. i never saw this many people solving such problems :') (and apparently, there's YT channels and Telegram channels that provide the solutions, wow)
" I can't believe this many solves on F of Div 3"
And I can't believe the authors decided to keep a CSES problem with next to no tweaking for F. Even LeetCode doesn't do it these days. Any one who had solved Xor Pyramids before would cheese through yesterday's F and those who hadn't even if high rated would struggle figuring it out. Though I happened to be on the befitting end, I feel it isn't very fair to keep CSES problems in an official round since it's the most popular sheet out there.
Can anyone explain the solution of G ??
for k <= sqrt(n), compute digit by digit for sqrt(n) < k <= n, rev(n, k) = n % k * k + n // k = n — n // k * k + n // k, we can partitions k by the value of (n // k) and compute each partition in O(1) for k > n, rev(n, k) always equal to n
one of my answer got accepted yesterday , but right now it is showing in queue it it normal or any glitch here??
same here two of my answers are now showing in queue but yesterday they were accepted. pls let me know too is it normal or not...
They are in System Testing currently. all submission will be judged within few hours.
Hello! Why i'm getting wrong result in check #2 in problem A, while test results and check #1 are right?
you are not adding for remainder when checking n>number_of_available_Steps
Editorial?
dont cry about The contest
CooL people can write comments using handles Only
just wait till THE_THUNDERSTORM_BEGINS
lol
.