Hello!
On Dec/08/2024 17:35 (Moscow time) we will host Codeforces Round 992 (Div. 2).
The problems were written and prepared by Igor_Parfenov.
I would like to thank everyone who made this round possible:
- 4mda4mda, zap4eg, triple__a, Non-origination, _Israel_, ApraCadabra, FzArK, Dominater069, ezraft, thenymphsofdelphi, Pervushev, Arthas, Khomutov for testing the round and providing feedback to the problems
- Vladithur, for coordination of the round
- MikeMirzayanov, for Codeforces and Polygon platforms
- All participants
This round will be rated for participants with rating lower than 2100.
You will have 2 hours to solve 6 problems.
Score distribution: 500 — 1000 — 1500 — 2000 — 2250 — 2750.
Good luck!
UPD: Editorial
UPD: Congratulations to the Winners!
Div.2:
Div.1 + Div.2:
Shortest description for a Codeforce Round I've ever seen. Good luck all :)
I Love short description :)
I'm just glad that there isn't any interactive problem.
yeah me too
Hope for the best :o, :D , :)
as a non-tester i love playing undertale
as a human, i also love playing undertale
what's the fun of playing undertale ? I don't get it.
Hope B will not be a Game theory
Hopefully, the problem statements will be short and precise just like the announcement!
maybe the keyboards battery died after those lengthy problem statements so now we are left with this short description
possibility
Can you explain to me why does everyone care about score distribution? I don't get it. Does it correlate with the complexity of the problems? And if so, in what way?
Yeah higher the jump in between the problems higher is the difficulty change
So am i right that this contest is going to have a significant jump between first 3 problems? Cause it's much more often them to be like 500 750 1250.
You can expect so. Usually a distribution of 500-1000-1500 means the problems are rated around 800 — (1000-1200) — 1500 respectively. There are exceptions of course (the last two div2s having 800-900-1200 and 800-900-1300 for example). In fact, a 1400-rated problem B in one of the recent div2s only granted 1000 points.
I think that 500 1000 1500 is more common than 500 750 1250 though.
Thanks!
I hope to become Expert after this round 0 ^ 0
1
wtf , undefined
$$$x^x$$$ approaches $$$1$$$ as $$$x$$$ approaches $$$0^+$$$
Limits Magic Sir
https://en.wikipedia.org/wiki/Zero_to_the_power_of_zero
for example https://judge.yosupo.jp/problem/sum_of_exponential_times_polynomial
thx sir , I'm aware of this :D .
hey can you give me tips how did you rise up so fast?
I have studied CP for nearly 3 years but new on codeforces :))
i see thanks
My first unrated Div.2
good luck
Best of luck to all participants—let's enjoy solving and aim for new personal bests! ᓚᘏᗢ
everybody best of luck give your 100% with best wishes
I want a rating boost, so should i go with solving problemB first and then problem A?
If you get a WA at B its over
xD
Expecting increase in rating
As a tester, I hope you get a lot of green in this contest.
As a tester, the contest is a friend.
which includes green stocks?
P.S: it is only a joke. I never bought any stocks.
Well, neither do I, so probably no :).
THANK YOU! VERY MUCH :)
it will be the rated contest number 100 for me <3
I hope to perform well in this contest ^_^
Hoping I could get to expert
I hope you all get greens
Normalize writing shortest description for every codeforces rounds.
Hopefully I wont choke on A this time :)
constructforces
i feel so stupid failing c
Problem C type of problems are the worst.
patternforces
C is going straight to my suicide note.
Is F on Burnside's lemma?
can someone explain to me the idea behind b i feel too dumb tbh...
the optimal indicies for the first operation are 1, 4, 10, 22, ....
yea.. i thought it would be something like this but i don't understand why
wont the (r-l+1)/2 > the sum of 1s ?
after choosing index 10, then we have 10 ones [1, .., 10], and we choose 22, then we have 11 ones between 1 and 22, then all between will be ones also, and so on ...
If the count of 1 in an array of length n is
>= n / 2
, then it can be made an array consisting of all ones using second operation. Now, to perform second operation, the endpoints of the subarray must be equal to 1. Hence, we can start constructing the answer from the smallest most optimal subarray, which is1 0 0 1
. Now, after applying second operation, it would become1 1 1 1
. Again, to fill next 0's, we can add another 1 after (k + 1) zeroes where k is the current subarray length which is all 1. The array will become1 1 1 1 0 0 0 0 0 1
, notice that count of 1 is still >= n / 2. This way, you can bruteforce your answer for any n.oh ty now i understand
i forgot to count the 1 after (k+1) to the count so range was always shorter
why are we putting 1 at 10th place since
ceil((10-4+1)/2)==4
which would be less than the sum of a4+a5...+a10 which would be 2,Thus we will never be able to perform 2nd operation between 4th and 10th index as 4>2
After we make 4th position 1, we can do second operation and we have something like
1 1 1 1 0 0 0 0 0 0
So now you see we can make the 10th index as 1
as (10-1+1)/2 == 5
Thanks,
Got it now
a bit constructive first paint the cell 1 then check how much i can cover by painting ith cell that will satisfy l=1,r= ith cell ,then (i-1+1)/2
a pattern like 2*(curr+1) will be formed please write it on pen paper you will surely get it
my code : https://codeforces.net/contest/2040/submission/295579978
https://codeforces.net/contest/513/problem/B2
lol
This explains so many submissions on C, despite its difficulty being near 1800.
How did you find this problem?
Oh no, its the exact same task !! Authors please be careful from next time bcz many people might have known this so its a bit unfair for us.
Authors: solve the same problem for multiple testcases. lol
D is serious?
How to D?
Keep track of a value you will assign to the nodes, starting at 1. DFS and use precalculated sieve to determine when a parent-child value difference is prime, in which case increment the value by 1 until it is no longer prime. The number of increases is upper bounded by about n/2, which ensures the value never exceeds 2n.
Guessed it would be solved like this. Thanks!
Just fill everything in dfs with odd numbers starting from 1. When you fill children of some node u, skip odd number x + 2, where x is the parent's odd number. In the end you'll have at most one unfilled node, so just fill it with even number x + 1, where x is the parent's number. It works because the difference of two non-adjacent odd numbers is an even number greater than 2.
Thanks
Another solution: solve in dfs order for subtrees first, then when combining add 1 to the whole first subtree and starting from the second subtree add double the size of all previously considered subtrees plus 2 to the whole now considered subtree. After the first dfs, the final answer will be obtained by going to the leaves from the root and adding all calculated values plus 1.
Thank you
C I gave up on observations and just generated $$$n=8$$$ permutations and found patterns
that's the first thing to do for permutation problems
Can you explain further? Did you do this on pen and paper (seems like a daunting task), and if you did this via code — did you calculate S(P) for all of them manually?
Yes, I did this in code and calculated S(P). Python has many nice features that make this pretty straightforward and fast. You can use itertools to generate all the permutations easily and S(P) isn't too hard to code.
what was the pattern I sill didn't get it?
Get binary representation of $$$k - 1$$$ with the number of lead zeroes that makes the binary string's length $$$n-1$$$. Then iterate over the bits. If $$$i$$$th bit (1-indexed) is $$$1$$$, then add $$$i$$$ to the tail of the permutation. Otherwise add $$$i$$$ to the head of permutation. Then there is only one number left, $$$n$$$, which should fill the only index not yet considered.
I started by thinking of maximising sum of intervals of each length. Realised you can't really get better than, say, for n = 5, for intervals of length 2 you can get at best 1 + 2 + 3 + 4. Then for length 3 you can get at best 1 + 2 + 3. And so on. And eventually realised that every piece besides the biggest one has to have as neighbors both a bigger and a smaller than it (considering the edges of the permutation to be 0). So essentially this is like going through the numbers in order and putting either smallest position still possible either biggest. So, like this, for example: n = 4
This can also be written then as either putting left or right. So for the given example it's L R R (you put 1 to the left, 2 and 3 to the right, 4 in what remains). And then finally when I started listing how all combinations of L and R would look I realised that this if you put the combinations in order, their results will literally be in the same order lexicographically, too (if you consider R bigger than L).
Same. I lost track with pen and paper at $$$n = 5$$$ so I just coded up a brute force construction method and then it's pattern seeking from there.
When will the editorial be published?
mathforces
stfu
Today I learned that 2 is a prime number :(
Lmao
C was too tough for pupil and specalist Guys.We cant even fight to solve C. Totally Disappointed
As a pupil, I did solve C
you've done a great job.
But an average pupil/specialist might not.
If average pupils solved C, I don't think they would be pupil
That C was way too hard for an average C. An average C is solvable for an average pupil.
I agree on it being harder, but I think people solving ABC are specialist, not pupil.
True.
Nah, it's just a find-a-pattern problem, not much knowledge is required to solve it.
C is painful for me
No idea how to solve C :(
Do a brute force to find the optimal value sum first and then see all the permutations that give the result for some small $$$n$$$ like $$$7$$$. Try to see the pattern.
For $$$n$$$, there are $$${2^{(n - 1)}}$$$ permutations with a special structure.
I honestly dont get the point of questions like C.
I liked C but it might have been harder or just as hard as D, which is not very cool. Also someone said they found it somewhere on codeforces, so, it shouldn't have been in the contest.
nvm
I brute forced and saw the pattern for C, but I couldn't figure out how to implement it for 90 mins, got really frustrated by the end of the round
same, couldnt figure out how to do it without computing 2^n
2^n gets really big really quickly, so you only need to do it for small n (Like <= 50). Then the large case is trivial, because it will be bigger than k.
same bro despite of finding the pattern it is difficult to implement it Does anyone knows how to solve such type of problems please explain , it is much needed ?? Please
you can literally solve this particular problem by making observations and "wishful thinking". See my comment above. But yeah, running bruteforce and figuring out why it looks like that might be faster than what I did. Regardless, realising when to call it quits and run a bruteforce and pattern match is still a skill, isn't it?
same :(
help in d please
My thought process : choose 4 as diff and then choosing adjacent node
one will act as root and all nodes in it subtree will be 1 given 1 and increment of 4 , other with 2 and it increments
counter case : for star graphs case i can take other additions also like 1 and 7 for additional nodes,
can't implement it so need help
That would be quite weird to try to implement, so instead of using 4 as the smallest non-prime, use 1 and see where that gets you. That's how I did it.
tried implementing the same
These ppl didnt mention the function in B was ceil, and not floor, and spend half an hour on that lmao, next time hopefully they write its ceil function
The one that is closed on top ($$$\lceil x \rceil$$$) is ceil, the one with the closing under it ($$$\lfloor x \rfloor$$$) is floor.
$$$ceil(x) = \lceil{x}\rceil$$$
$$$floor(x) = \lfloor{x}\rfloor$$$
$$$round(x) = \lfloor{x}\rceil$$$
C was way too tough ig
I wasted so much time rabbit-holing in B... so I did D and then came back to B, spent another 20 minutes, and then finally saw the easy way to do it smh.
how did u assigned nodes
I answered how to solve D in a comment above.
is there anyone found $$$D$$$ was easier than $$$C$$$ ?
really thought so
i found it easier to solve, but much much harder to prove
can u tell why am i getting tle?
d
I think your problem is with this line
try to optimize your approach to find this value in $$$O(log(n))$$$ instead of $$$O(n * log(n))$$$
i found E < C < D
why is d getting tle d
This was not competitive programming, this was competitive math
more like get the k-th unimodal permutation competitive googling
Yeah, it seems to be a very fair thing to not tell explicitly that you are using ceil function instead of floor and then don't even add testcases to make sure it doesn't happen. There's barely a difference between ceil and floor brackets and anyone can genuinely miss it.
guessforces + how on earth none of testers noticed about C
dear problem setter, please never make problem like C again, never.
make this unrated wtf
I couldnt implement C for 1 hour I feel like I am stupid.
Am I the only person who really liked C? Only reason I found out it was hated was by looking in the comments
It is cool but it appeared before.
Once a Div.1E problem was already googlable , and the contest was rated
74 Magic
Yeah, that's really annoying (learned of that after I made the comment), but we've had contests where there's been non-original problems that haven't been unrated (see https://codeforces.net/blog/entry/135494?#comment-1219485 ), so it's possible that it will still be rated, but I can't say.
pretty sure your code is copy pasted. A lot of newbies and pupils have the exact same code as you. Its an already existing question.
1) If I copy and pasted the code, why would I have gotten a WA for my first submission
2) I do that in my submissions in-contest, eg https://codeforces.net/contest/2037/submission/291988558
And since you decided to change your comment's meaning, point 1 still stands. I've never seen the problem before, and I swear on that (for a bit of extra proof, here's the bruteforce solution I wrote in contest, Ik it's not perfect proof, since I could have written it after the contest, but here)
Well there are some coders who name variables very explicitly, like neal, for example. (I am replying to the first version of your comment)
yeah but when people below 2000 do it its usually gpt generated or copied from somewhere.
If you want more proof, here's a problem I solved before o1-mini was released: https://codeforces.net/contest/1993/submission/274367607
d is too hard for me :(
F is combinatorics, not constructive
The "F" in the pic doesn't seem to reference a problem.
Actually one of your homies loves constructive problems
I'm sure for many, the D task was an attempt to just stuff something stupid without even trying to prove it. It's a pity that I only managed to do it after the end of the round. Specifically, C was too heavy for me.
C binary search solution: 295643209
I cheezed D with a randomised solution. Basically, I guessed that the ratio of number of "unblocked" values to total values is never much lower than 1/2
haha loved that!
But can it be hacked?
Did you prove that there are no impossible inputs?
People fighting over problem C, and my stupid brain thinking it's a floor operation in problem B.
Never let this author cook again.
Who and for what reason decided to add -1 in Problem D?
That's quite common as to not spoil the solution. Alternatively you have to guarantee that solution always exists, but that is not always obvious.
If they wanted to make the problem better, they could have added that maximum node should be as small as possible.
I think the problem is good as it is. How would you solve the modification you proposed?
Not sure, But I would Try to change my initial code which got TLE on 24 test, were I find the diameter of the tree fill with numbers which have difference of one and after that go to subtrees by increasing the number with smalles composite difference and do the same in there, but not sure how to implement it yet to pass in time.
[For problem C] I am trying to generate the permutation according to the bitwise representation of k. Could anyone please see what's the error?
You did the same mistake to me at my first submission,notice that shift=n-2 and R-L+1=n,this mean your shift you decrease n-1 times when L==R,in other word when L==R,your shift will decrease n-1 times,initially shift=n-2 and n-2-(n-1)=n-2-n+1=-1,you right shift (k-1) by -1 ((k-1)>>-1) will happen unexpected operation
Problem C was exact copy of problem : https://codeforces.net/contest/513/problem/B2
This is extremely unfair to the people who tried this problem for the first time. This also explains why so many people were able to do this problem despite it being good enough that most of my expert friends couldnt do it.
My submission for contest problem : 295640125
Exact same code submission for older version : 295644907
I totally agree with you. What are the testers doing? If it's a problem from another country's website then I can understand why they accidentally made the same problem. But another exact same problem from codeforces????? Insane. It is really unfair for ppl who didnt try this problem like me.
Yeah higher the jump in between the problems higher is the difficulty change
I found something interesting while reviewing the official common standing: three participants younesg (rank 2), Constantor (rank 7), and CLAY (rank 15)—all failed to solve problem D. Upon examining their code, I noticed a significant similarity in problems C, E, and F. Although they paraphrased the code quite skillfully, it’s evident from problem E that there’s clear code plagiarism among them (295598220, 295609438 and 295632243). I hope MikeMirzayanov and Igor_Parfenov can address this case.
lmao auto and consts to try to avoid plagiarism
lol
How did u all solve 2nd problem , i couldn't understand the editorial someone help me, i thought of a diff approach which i got wrong answer but it was no-where near to this editorial approach please explain. Does this problem looks similar to some previous problem?? How to solve these types of problems I need some advice. This is my second contest and i wanna reach pupil but i guess problems like these are a problem for me
PLease help me how to solve problems like these with ease
You can think like this,initially we have no 1 in our array,if n=1,then we just need to add 1 to the array,and if n=2,also do the same thing add more 1 to the array then answer=2,but think about does n=3 we need to add 1 more? the answer is no,why?For example,you can add 1 in your second times like this ,[1,0,1,0,...0],the sum of interval [1,3] is 2 and the length of interval is (3-1)+1=3,ceil(3/2)=2,so for n=3,answer=2,and similary for n=4,answer=2,So according to this observation we need to make sure the 1 already been added into the array is completely use by us so for example if our array already become [1,1,1,1,1,0,0,0,.....0] assume that there is k times 1 in our array,then how much 1 i will get if i place my next 1 optimally?The answer is (k+1)*2,because you already have k times 1 and you add 1 more then you have k+1 times 1,and let s=(k+1)*2,obviously s/2=(k+1) which is satisfy the statement,so you can directly run a simulation to approach this and the time complextiy will be O(logn) and overall for all test case will be O(tlogn) which is under limit,below is my submission hope useful to you 295580740
In E, how to derive the expression "2 * sizeof(vertex) — 1"? Though, i guessed, after this move, move parity will be odd, so, we can go back to the same vertex, using 2 moves and one substraction for parent.
at any vertex you have two choices(if the step is even)- either go down to one of the child vertex or go to the parent vertex... the probability of going to a parent vertex is 1/degree while going to a child node is (degree-1)/degree. let E denote the expected number of steps to reach parent vertex then E= 1/degree + ((degree-1)/degree)*(1/degree)+(((degree-1)/degree)^2)*(1/degree)+........ . Solving this you get the required value of 2*degree-1.
did thet tutrioal of D's second idea is wrong,the"write the values n*2,n*2-1,…"should be "write the values n*2,n*2-2,…"
Yes, it was a typo, fixed now
Question C: What do you want to investigate?
Curious Patterns in Contest Submissions
Israel?.... get out.