Hi Codeforces!
On Dec/03/2024 09:25 (Moscow time) we will hold Codeforces Round 990 (Div. 1) and Codeforces Round 990 (Div. 2). Note the unusual starting time!
The harder problems of this round are based on the problems from the Final round of Yandex Cup 2024, Algorithms track, that will be held at the same time.
The problems are authored by elshiko, Flyce, MrLolthe1st, sokolow, stepanov.aa, TeaTime, Tikhon228, webmonster, 4qqqq with guest problems from myst-6, Vladithur, BledDest and me.
I'd like to thank daubi, Golovanov399, arbuzick, pperm, orz, AgafonovArtem, Qwerty1232, k1r1t0, Itsmylove1, Sofi_, and errorgorn for testing the problems, tourist for helping with the round, and MikeMirzayanov for the Polygon and Codeforces systems.
Because of official Yandex Cup Finals ends later than the round on Codeforces, the upsolving, solutions, and test cases will be closed until the end of the onsite contest, roughly 3 hours after the end of the Codeforces round. It is also forbidden to discuss the problems publicly until the end of the onsite round. Any comments here concerning the problems will be removed.
Good luck!
UPD: The contest has been delayed to make sure the online contest does not start earlier than the onsite one.
Congratulations to the winners!
Div. 1:
Div. 2:
UPD: You are free to discuss the problems now.
first comment :D
As a spectator, I hope tourist becomes Tourist again.
He can't participate when he already helped with the round
it was good decision .
How come the announcement is so short. At first I thought it's a blog. I think something missing....
After EDIT : What a mysterious contest without any information. like : score distribution, number of problems etc.
something IS missing.... the score distribution, but not that short.
that's mainly because there are only few testers, and there are not any words to describe more about the staffs, which could be veeerrryyy long. heres a example from rayan announcement:
Dear TheScrasse for his dedicated coordination efforts and lots of discussions about the problems and rejecting a big chunk of our problems for Problem C. He also contributed some problems to the contest, one of which was selected by the team!
hey why downvoting me, I don't mean that long description is bad! just explaining why the announcement is short :(
well not everyone has time or energy to post things like :
A super greeting (sometimes in native language)
ORZing co-ordinator , particular problem setter with sweet words with unlimited adjectives and follow up stories
Group photo in restaurant with problem setters
Some even start donation movement
It is KAN's style to annouce very short.
7AM contest? Thank you, next :p
Weak
*wweak
underrated
There's no way you're complaining. For me, literally every single contest is either at 6AM or 7AM depending on daylight savings. Sometimes 8AM if it is daylight savings and delayed start, or 1-2AM for unusual start time. This one is 10PM.
Looks like a fellow PST member! I sleep early on weekends so I can do codeforces contests at 6:35 AM during the winter. I'm honestly happy about this 10PM contest, I think its a better time than 6:35 AM.
Yup! I much prefer this 10PM contest.
bro needs a few more 2 am contests lol
yeah it's literally specifically 1am i bomb 10pm contests too clearly i need to be more sleep deprived
I don't really understand the "There's no way you're complaining". I definitely do not complain about the general situation, where median CF round is at 15:35 for me. I will definitely not be participating in any round starting at 7AM, so that timing is bad for me and my initial post didn't mean to say anything else than "I am not a functioning person at 7AM" in a humorous way. In particular I didn't mean to say that the decision is objectively bad cause I am aware people in other timezones exist, neither did I want to complain like "why are all cfs round so badly timed?", cause I am aware I am in a favorable timezone for the vast majority of contests. Sorry if I came off as entitled or something
Painful time, but I'll take what I get. At least this time I was able to go to sleep early so I wouldn't fall asleep while typing, and it was well worth it.
What will be the score distribution?
who are the finalist ?
https://cphof.org/advanced/ya_algo/2024
Are finalists allowed to check the standings of the Codeforces contest during the round? (if not, how will this be enforced)?
Given that the Codeforces contest ends long before the final round ends, how is it ensured that discussion doesn't begin until after the final round ends?
Best of Luck Benq
Now that I read the announcement, why didn't they sync the contests' end times instead of start times? It's easier to control problems not getting leaked when contest is on-site.
will the rating changes for the edu contest will happen before this contest ?
Does the color of your avatar always match your rating? lol
YES ^_^
Please change the start time, I have a school!◑﹏◐
What happens if someone changes from Div 2 to Div 1 (or vice versa) in Edu 172?
The round starts too early after the end of the hacking phase of this Educational round, so there may not be enough time to run system tests and update the ratings before the round. Also, even if it were possible, changing divisions requires re-registration and it would be chaotic to let people do that in such a short time.
So yeah, my assumption is that people are assigned to divisions according to their current rating, and the result of the Educational round won't affect it.
That would make things somewhat weird. Imagine someone seeing a master in tomorrow's official Div2 standings in the near future!
It's not the first time this happened. For example, you can see some masters in https://mirror.codeforces.com/contest/1981/standings because it started not long after https://mirror.codeforces.com/contest/1976 .
Wow! I didn't know that. It's still as strange as it is cool, though.
When will we know the score distribution?
which is harder?div1 or div 2
Div 1
thank you
what a problem !!!!
What's the score distribution??
arcane s2 is masterpiece
The contest is in less than an hour. When will the score distribution get released?
In less than an hour. I think they're gatekeeping score distribution because it's an on-site contest too and they may have different rules in place regarding stuff like this.
What's the score distribution??
because of the School Sports Day,I can't take part in this round(in fact,at weekdays students can't use computers during the time in school
Why did contest get delayed?
Benq's comment probably
Good, I can take a power nap.
The contest has been delayed, and we want to go to sleep
edit:wish i was sleeping
Did it just get postponed by 30 minutes?
One refresh costed me 20 minutes :(
hoping for +420 :)
The more the contest delayed, the higher chance we're gonna lose our rating >:
Goodluck to everyone
Where is the score distribution?
KAN dont be lazy, upload the score distribution for div2 atleast
I am participating just to solve problem E. Hopefully there are at least 5 distinct problems :)
score distribution?
Speedforces again. :(
Speedforce!!!Problem D-F is much more difficult than A-C,making it into speedforce...
I think good problems, thx to all
Please avoid discussing the problems in public, including but not limited to this blog, until 11:10 UTC.
2 hours is not enough at all, why not 2.5h or 3h???????? (for div.1)
why not 4h??????????????????????????
Trash round.
True, having 2 hours in a Div.1 contest really feel like another speedforces round...
Div1 CF rounds have been 2 hours long historically and still sometimes are. Speedforces isn't a time problem but a balanced difficulty distribution problem.
I agree, that said, it would be nice if the round was a bit longer for slow solver like me (2.5h for example).
Lack of balanced problemset AND time makes it into speedforces round. More time can somewhat compensate for unbalanced problemset.
No, speedforces is the problem that occurs when there are way too many problems with way too few solutions and the rest with way more, so even people high up on the scoreboard are ranked mostly based on solving time. Giving more time will only slightly increase the number of successful solutions of those too hard problems, but also increase the number of people who end up with all easier problems solved, so it'll most likely make speedforces even more extreme. It's like trying to solve your gambling debt problems by betting all you own.
"...so it'll most likely make speedforces even more extreme. It's like trying to solve your gambling debt problems by betting all you own." that doesn't make sense. In the end everyone who solved all easier problems would have a speedforces round (which wouldn't be more "speedforces" than without additional time), but those who solved one more hard problem would have more of a fair cf round experience (I mean being slow wouldn't punish them that hard). So I don't think giving more time would make it more speedforces.
Those very few who solved one more hard problem. When there's a massive jump in number of solutions, there's a reason for it and that reason isn't just lack of time. Also saying "it doesn't make sense" isn't an argument.
I think in this round, there was quite a lot of implementation, also for the harder problems. So time was really a decider if you could just program your idea in time for one of the harder problems.
Even if the number of participants who solve one more hard problem is very few (which you don't know for sure) does it mean it is not worth giving more time? I don't see any harm of writing a 3 hour contest instead of 2 hour contest even if it helps like 20-30 people.
Maybe for someone the reason is lack of time.
Sorry, didn't mean to be rude.
Trash round.
D looked so easy but turned out to be super difficult for me.
Can someone share the onsite final ranking!
nvm //I assume systests will also only run afterwards?
-ve delta for solving a-d :(
how do u calculate your delta before the results?
Carrot
What's your rank?
i attempted with my alt (newbie) account did a-c in 50 min carrot is showing -ve delta
too hard.
agreed
I think I've seen problem 1C before
A similar problem (with differences but almost identical solution) is USACO 2016 February Contest, Platinum, Problem 1. Load Balancing.
It's similar to this problem 105003C - Equipartition, but a bit harder / more annoying.
What was the initial start time (before it was delayed)?
8:05 iirc
System testing is over, when can I submit?
Edit: Ok, I see, about 2.5 hours more
why where's an easy 1C with TOO HARD D&E&F :(
1E is not hard
man,what can i say,haha,oi out
Hello everyone!
We're currently streaming the final round of the Yandex Cup Algorithm track.
During the broadcast, we're also discussing the final problems with the competition judge. Join the stream
We're discussing some problems in Russian, and some problems in English as well.
The difficulty difference of this contest is too big.
Yep.
pls someone check on orzdevinwang, hope he will be ok
He flew so close to the sun that his wings burned
...
Is this round rated?
Yes,it's rated.
OK, thanks. I was confused because I didn't know that the contest would be marked as unrated until the ratings have been calculated.
Was this contest rated, cuz it's showing in the unrated contests. If it was rated, then do we have to do something while registering to attempt the rated version?
It is 11:32 UTC, but the editorial didn't appear... So how div2F?
For DIV2 C I solved the problem in O(n), but I didn't see that the constraint wasO(n2) . Why was it O(n2) when someone can solve it in o(n)...
may be for DP solution, Edit : and its not n^2 actually even DP solution is possible is O(n) ig
Yeah I too solved using DP in O(n). Is there any solution for greedy + sorting as mentioned in the tags??
hint : consider we have some arrangement after swapping which would lead to optimum path, here from each column we can consider one value except for one column where we take both values in that column through this column we can shift from first row to second row, think abt it
Lesson learned: never ternary search on a series that had non-extrema duplicate... Costed me Div1C because of this newbie error.
Could you elaborate?
You also did a sweeping line algorithm and then tried ternary search with segment tree? That would have been my approach if I actually thought of it faster. What should have been used instead of ternary search? Or it the solution completely different?
Instead of ternary search the series itself, binary search its difference (since that is monotonic) — you'd need the first element that the difference changes sign (equal to the position of the extrema).
UPD: I think I made another fatal mistake... the difference is not monotonic.
Finally I found the correct idea, and it's not relevant to the OG ternary search.
Instead of searching for the $$$y$$$ that would yield maxima for each $$$x$$$, we search for the actual answer instead. We see that to reach a specific answer, there will only be a range of $$$y$$$ supports that for the half "behind" (having x-coordinate lower than current $$$x$$$), and another range of $$$y$$$ supports that for the half "infront". If those two ranges intersect, then such answer is possible.
Added with pooty's comment (though I didn't do the exact bruteforce they intended), the number of searches could be lowered enough to fit into TL.
My submission (very sketchy): 294633915
I did something very similar (and made the same mistake you did with the ternary search idea when I tried to upsolve lol), my solution (294702082) ended up running in $$$O(n \log^2 n)$$$
Can just do brute force, since the best answer can only increases as u move on one axis, so no need to check if its possible all the lower answers as you move (i assume your approach is similar to mine)
Did you mean ternary search will not work on array like this 1 1 3 2 2?
I meant something like $$$1 \, 1 \, 3 \, 2 \, 2$$$. Your case is binary-searchable.
Yes sorry I didn't pay attention well, for the case 1 1 1 1 1 3 2, If you tried ternary search it will give 1 instead of 3, thanks for let us know this mistake. And in case of duplicate non extrema value, find the position where the sign change with binary search can also be tricky as 0 can be considered positive or negative, what should we do in such situation?
Yikes, thinking again, I might screw up once again. The difference is not monotonic to binsearch.
As in, if you found that a point where its possible get a minimum of k already, as you move along one of the axis, you just need to check if its possible to get a minimum of k+1, etc
me too.
Why is input validator for c set to 1e5? Trying to hack and it gives me
There is no max test case aswell, checked with assert.
The correct limit is $$$10^5$$$. Somehow missed that when decreasing constraints.
how can we solve problem E?
i thought finding median of x and y would be enough but it seems i oversimplified the question
What is the solution for div. 1 C?
First let's binary search the answer, call this x.
We'll check whether it's possible to obtain this answer by doing a sweep line on the x-axis. Now we need a data structure that supports quick point update, range query. Let's maintain 2 of them, $$$left$$$, and $$$right$$$, we'll add the points by their y-coordinates and whether they're on the left or the right of the current x position we're checking, add all the points such that it's x coordinates is at least equal to the current x to the right, else to the left. Now we can just binary search for the smallest y such that $$$left(-1e9. y)$$$ >= x, and $$$right(-1e9, y)$$$ >= x. After that, we can check if $$$left(y + 1, 1e9)$$$ is also at least x, same thing for right side, now we have our answer
Thanks, I thought the question need some complex data structure or something like that and got completely stuck. Seems so easy now, thanks!
Any good source to learn sweep line?
Does this pass comfortably within the TL? I believe the second binary search along with the data structure queries would make the overall complexity $$$n\log^3{n}$$$ right? If we use a segment tree with the walk on segment tree technique then it can be reduced to $$$n\log^2{n}$$$, which is what I tried to do, but got TLE on my first submission 294679397.
After this, I tried removing
#define int long long
, then it passed but the runtime was 2999ms, which is very very close to the TL (294679509). I then tried the same thing in C++23 instead of C++17, that passed in 2499ms.This is probably because of segment tree having a high constant factor, but using segment tree also reduces the complexity from $$$n\log^3{n}$$$ to $$$n\log^2{n}$$$, whereas in a fenwick tree there isn't this concept of 'walking on segment tree' right (I might be wrong here but I haven't come across such a thing in fenwick trees)? So I'm guessing with fenwick tree this approach will be $$$n\log^3{n}$$$ but with a lower constant factor, which is comparable to what I have submitted.
I'm aware that there is another approach where we can do something like two pointers instead of the second binary search to find $$$y$$$ which would further eliminate a $$$\log$$$ factor, but without that, what would be the best way to go about the binary search approach?
You can implement lower bound on fenwick tree in single log https://github.com/kth-competitive-programming/kactl/blob/main/content/data-structures/FenwickTree.h
I implemented both $$$n log^3$$$ and $$$n log^2$$$ solution for Fenwick tree, in which $$$n log^3$$$ passed in ~500ms, and $$$n log^2$$$ in around 320ms. I believe segment tree should easily pass as well. You can check out my submissions for more details. I think something else inside your submission is the reason for the high runtime
Update: I submitted a $$$nlog^3$$$ solution using segtree, you can see it here: 294698721, it runs in only 1500ms
I used a pbds instead of a segment tree and got around 500ms (294708443)
hello can anyone guys explain he's solution for problem D and big thank !!
can D1C/D2E be done with geometric median?
would it even be practical? That would require big number arithmetic. And I don't know if the constant/time complexity for those won't be too large.
I don't completely understand geometric median but I think it would provide incorrect results for the following testcase:
When Editorial?
Do you have a solution to the problem?
Problem "For the Emperor!" is very beautiful! GG to the author <3
How to solve it (Div1 D), though? I tried some min cost max flow approach but couldn't figure out how to give a cost to the whole edge (and not to using a unit of an edge, as it is normally the case in min cost max flow).
I created 3 nodes {s,in,out} for each SCC, which I explain below. Sorry it may not be very clear, but the general idea is to maximize the number of nodes "covered" by a path, which is done by having a cost of -1000 per covered vertex, and as a secondary objective, minimize the total number of paths that start with an original copy (by having a cost of 1 per path).
So for example if at the end we find that the cost is -4997, it means we needed 3 original copies to reach 5 nodes (-1000 * 5 + 3).
The edges for a SCC compressed into a node $$$U$$$:
$$$src \rightarrow U_s$$$ with capacity equal to the number of messengers in that SCC, and cost = 0. This node $$$s$$$ acts as a splitter to ensure we don't exceed the total number of messengers across the outgoing edges below.
$$$U_s \rightarrow U_{in}$$$ with capacity=cost=1. This is to minimize the number of paths that actually start at the vertex with an original copy of the plan (the required answer). We need at most one copy per SCC.
Finally the DAG edges between compressed SCC nodes ($$$U$$$, $$$V$$$) would be added between $$$U_{out} \rightarrow V_{in}$$$. You can check the
addEdge
calls in 294690574.Wow, that's cool, thank you! :)
Div.1 F1 and Div.1 F2 are completely different problems. I don't understand why this kind of subtask is allowed in a cf contest.
Problem div2 E is very similar to 2016 USACO Platnium’s load balancing problem: https://usaco.org/index.php?page=viewproblem2&cpid=624. Just a cool observation.
https://mirror.codeforces.com/contest/2047/submission/294647087 can someone pls see what am i doing wrong , its coming wrong ans for 'hhmv', when i custom run it, its giving the correct output but in the codeforces tested result its coming wrong , i am new to cp in python, pls correct me where its wrong
python dictionaries are not ordered, so what might be happening is that you and the judge are going through the items of y in a different order. For the "hhmv" test case in particular your code fails if h is the first character being checked, the first if saves h as the element with minimum frequency, and the second if block does not run because repl1 = 'h' now, so h doesnt get saved as the element with maximum frequency, so at the end the wrong characters get replaced
Makes sense, and its an easy fix to make the minimal correct everytime, thank you so much for the help, much appreciated
I think 1C is too easy and 1D is too hard. Maybe adding one problem between 1C and 1D would be better?
Despite popular belief, I think this is an excellent contest because I gained quite a lot of rating. Luckily, I chose to solve E1 instead of D, since I noticed the points awarded is lower (so probably easier), and it paid off! Would like to see more contests of this sorts:)
Are there any tips about the problems in div2?
1E feels like a Div2C. I wonder why so few people solved it.
I guess many of them were stuck in D. I personally think E1 and F1 are both much easier than D.
Editorial waiting room...
didn't participate in the contest, but I'm happy I managed to do a div2 D for the first time lol (without searching etc etc)
why this post is getting many dislikes ?
I don't understand why problems were oredred like this. In my opinion, F1 is much easier than D, and the gap between C and D is way too large. It may be better to put F1 (maybe also E1) between C and D, so that some participants could have something to do in the last hour, instead of wasting time on a much harder problem.
The score distribution literally tells you that E1 and F1 are both easier than D...
rating of C question?
When do we have the tutorial?
Editorial when?
Passed more than 1 day but no editorial is published yet.
When can I read the editorial?