Codeforces Round #902 (Div. 1, Div. 2, based on COMPFEST 15 β Final Round)
source link: https://codeforces.com/blog/entry/121025
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Sugeng enjing, Codeforces! π₯°π₯°π₯°π₯°
COMPFEST 15 is happy to invite you to participate in Codeforces Round 902 (Div. 1, based on COMPFEST 15 - Final Round) and Codeforces Round 902 (Div. 2, based on COMPFEST 15 - Final Round) on Sunday, October 8, 2023 at 09:05UTC. Both rounds will be rated. You will be given 2 hours and 30 minutes to solve 7 problems.
Note the unusual time of the round.
The problems are written by ArvinCiu, Pyqe, and nandonathaniel.
We would like to thank:
- KAN for helping to host the round;
- errorgorn and ScarletS for the based coordination;
- gansixeneh and nandonathaniel for helping with the problem preparation;
- ArvinCiu, CyberSleeper, and Edbert.H for providing alternate solutions in the early stages;
- Alexdat2000 for writing the Russian translations;
- Aaeria, AMnu, Berted, BucketPotato, buffering, Drew_, dorijanlendvaj, eggag32, Elben85, emorgan5289, faustaadp, ffao, fishy15, flamestorm, gamegame, hocky, Insta-x, jdurie, joelgun14, KerakTelor, Marky, Murinh0, nvmdava, nyab, Owmicron, prvocislo, PurpleCrayon, rama_pang, TakeMe, sahil_k, user202729_, Vladithur, WHCPP, and ZeroScar for testing the contest and providing us very useful feedback;
- Universitas Indonesia, all the local committees, administrators, and managers of the whole COMPFEST event;
- MikeMirzayanov for the amazing Codeforces and Polygon platform!
COMPFEST itself is an annual event hosted by Universitas Indonesia. It is the largest student-run IT event in Indonesia and competitive programming contest is one of the competitions hosted.
We hope you will enjoy and have fun in the contest. Muga-muga beja lan isa entuk biji apik!! πͺπͺπ₯π₯
UPD: Scoring distribution
- Div. 1: 500 β 1000 β 1250 β 1750 β 2250 β 2750 β 3250
- Div. 2: 500 β 1000 β 1500 β 2000 β 2500 β 2750 β 3000
UPD2: Contest is over!
Congratulations to our winners!
Congratulations for our first solvers:
We will try to post the editorials as soon as possible. Please stay tuned!
UPD3: Editorial
On behalf of the COMPFEST committees, we are glad that our Codeforces Round ran quite smoothly and we hope that you all enjoyed our problems. See you next year! ππ
3 months ago, # | can anyone explain what does "based on COMPFEST" means ? |
As a tester, I am forbidden from commenting on the announcement post with any opinion. |
3 months ago, # | What is the meaning of Muga-muga beja lan isa entuk biji apik!! |
3 months ago, # | As a tester I can assure you the problems are very **********************************. |
3 months ago, # | The starting time was really weird but i guess it will be held on sunday after all |
3 months ago, # | Finally a new round after 8 days :) |
3 months ago, # | Contest, finally. |
3 months ago, # | Not Every Country in the whole world observe a holiday on Sunday. In my country, Friday and Saturday are the two off-days in the week. And Sunday often is the busiest day of our schedule as it is the beginning of a new weekend. IF YOU COULD HOLD THAT CONTEST ON SATURDAY IN SUCH AN UNUSUAL TIME, then no people in the world would have had any problem as Saturday is the intersection of two traits of holidays.(friday-saturday based holiday like my country and Saturday-Sunday based on the majority of the country). |
-
Certainly I agree with your idea. The unusual time is unfriendly for both Chinese and Americans. For Americans, it seems harder to wake up so early. And for Chinese, there was a National Day holiday until 6th so we had to go to school or work. We are still studying or working at 17:05. However, I can accept the usual time, 22:35 because I am allowed to stay up late at my dormitory.
3 months ago, # | Good luck everyone, Remember, you don't lose when you fail, you lose when you give up. |
3 months ago, # | what will be the score distribution system? |
3 months ago, # | Tomorrow I will fall 100 rating in CF first and then fall to blue in ARC. |
3 months ago, # | Hope I have good luck. |
3 months ago, # | Waiting..................................... |
3 months ago, # | what will be if you win ? |
3 months ago, # | Please note the unusual timing of the round |
3 months ago, # | are COMPFEST div 2 problems harder than normal div 2 problems? |
3 months ago, # | Muga-muga beja lan isa entuk biji apik!! Sound interesting, What's that mean? |
3 months ago, # | Please announce the score distribution system. |
3 months ago, # | As a participant I hope to get 1200+ rating or even better, Pupil **** |
3 months ago, # | Good luck everyone. |
3 months ago, # | Thankyou |
3 months ago, # | Why are there so many problems(like 7 problems) in recent Div1 contests? It's hard to adapt. |
3 months ago, # | Hey King π you dropped "score distribution" |
3 months ago, # | best wishes |
3 months ago, # | clashing with icc world cup |
3 months ago, # | Who wants the cantest to start at 14:35 UTC? |
3 months ago, # | Finally, Chinese Oiers don't need to hold up to 1:05 evening. :D |
3 months ago, # | This round may be Indonesia-friendly. However, many of Chinese OIers are able to participate in this round because they don't need to stay up late :) |
3 months ago, # | 265 forces |
3 months ago, # | The Scoring distribution is opposite in the announcement, swap div1 with div2. |
3 months ago, # | It seems D1 = 500 1000 1250 1750 2250 2750 3250, does it correct? |
3 months ago, # | i see that was found extra register so where is it |
3 months ago, # | Completed A-D in 40 minutes ,then nothing for 2 hrs. E>>>>>D. |
3 months ago, # | How to solve D |
-
Just iterate over every maximum value from to . Then, let's say = "count of indices that needs to be colored black to get a maximum of " and = "count of indices that when colored black gives a maximum value less than ". Then, the contribution for would be . Answer is the sum of over all .
3 months ago, # | Can anyone please help me understand the solution for DIV2 Problem D Thanks in advance :) |
-
If we select any index i to make it black we can replace arr[i] with the maximum value at any index j, such that i is a factor of j (because we would always be marking all such j green).
Then we can sort the resulting array, and now for the maximum element to be Kth from this array, we have 2^(k-1)*arr[k] possibilities, we can just calculate this sum for all the elements from 1 to n in the sorted array and take the remainder which would give the ans.
-
I'll explain my solution, maybe not most efficient. Basically, for each idx we go to the right with step idx to find the maximum value that this idx can lead to after coloring. It is similar to how we use of sieve of eratosthenes, although in our case we do it for every idx, not skipping already visited before. (Let's say idx == 2, we're going to check idxs 2, 4, 6, 8,... and store max value of them. For idx == 4 we're going to check 4, 8, 12,...)
After that we create dictionary value -> amount of idxs (that lead to that value after coloring them with black)
And starting with greates value to lowest, you have value: amount of idxs. Let's say v: k. And let's say amount of possible numbers to choose from is n (it's n in the beginning). Amount of subsequences which contain at least one of numbers from those k numbers is 2 ** n β 2 ** (n β k). (total β amount of subsequences that don't contain at least 1 of those numbers). You multiply it by value v and add it to result. Then you do n -= k, as we don't want to consider those anymore. MOD at the end
3 months ago, # | WTF with D's nowadays |
3 months ago, # | What a great Contest |
3 months ago, # | I'm honestly really annoyed at this, can someone see what's wrong with my code because I've been trying to debug this for the last 20 minutes. |
Is my solution correct for D1C? For each of the directed subgraph, we need to find cycles and then there are 3 cases on some pair of adjacent nodes (pick both, pick first, pick second). For each case, apply dp and find the maximum count of nodes we can pick. Then backtrack to get all the picked nodes. Also, is there any simpler solution than this? |
-
I couldn't debug within time, but my approach was:
Consider the usual directed edges (i, A[i]).
If in-deg of a vertex = 0, then it cannot be circled. And so it's out-child has to be circled. And if we know that if a vertex is circled, it cannot circle its out-child, so decrease in-degree of its out-child (and if its in-deg becomes 0, mark it as not-circled, and push into the process-queue).
Keep repeating the above two points, until you end up with no vertex with in-deg = 0. So, in-deg of all 'active vertices' >= 1 and we already know that out-deg = 1 for all. So, in-deg = out-deg = 1 for all active vertices. So it's just a bunch of cycles. Iff all cycles are even, there's a soln.
3 months ago, # | How to solve D1C? |
-
given graph is cycles with tentacles
first β delete tentacles:
if there is no edges to a[i] ("end of tentacle") β it shouldn't be chosen -> a[a[i]] should be chosen β remember, delete them, decrease in-edges count for a[a[a[i]]] do this while you can β you can keep vertices with 0 edges in the set and add them when some vertex becomes 0 in-edged
ether everything is deleted or there is still untouched cycles
if there is cycle with odd length β cout << "-1". You can understand this from a cycle of length 3
if each cycle has even length β color them 1 0 1 0 1 0
-
First of all we will try to identify what indices or elements are mandatory to come and what are mandatory to not to come. For this we can make a frequency array and if freq[x]==0 , x as an index can never come in p and because x can never come a[x] must come in uncircled elements and as an index too and a[a[x]] must not come as uncircled elements and so on .... considering all these facts, first of all we need to identify mandatory presence and absence.
After this if there are any a[i]==i pairs or there are odd numberof indices left ans is -1 else an ans always exist.
3 months ago, # | In problem D the word indices should've been highlighted.. I wasted the entire time thinking that elements multiples of black elements will be colored green. Spoiler |
3 months ago, # | How to solve Div 1 C? I knew that it can be reduced to coloring nodes in a directed graph (in which outdegree of every node is at most ) such that for every node , if its color is , then, it must have outdegree and its outgoing node must have color , otherwise, if its color is , then at least incoming node must exist that have color . |
-
Yes, that's basically the solution. The only additional thing is that cycles have to be handled carefully.
Process each component of the functional graph individually, for each hanging tree, do subtree dp ( stores if its possible to not pick node after picking/not picking nodes from only its subtree and stores whether its possible to pick it). The transitions are the same as what you have written (its possible to not pick a node if all of its incoming edge nodes are picked, and possible to pick a node if atleast one of its incoming edge nodes are not picked).
Now, we need to check if a valid set of choices for the nodes on a cycle exists.
Pick any one node on the cycle to be the starting node. Fix the choice (not pick/pick) for this particular node, and go along the cycle, maintaining similar dp states (note that these dp states must take into account two things: the last node on the cycle, and the hanging subtree). The transitions are almost the same as when we find dp values for only hanging trees. Check whether there is a valid set of choices for both choices of the starting node.
Finally, you can just store backlinks and find the unpicked nodes to get the final answer. Unfortunately, my implementation is cancerous and belongs on r/EyeBlech.
3 months ago, # | When can I see others's code?I want to know the solve of Problem D... |
3 months ago, # | Weak samples are OK for ICPC problems, but absolutely disaster for CF. |
3 months ago, # | When will the editorial be posted? |
3 months ago, # | div2 C is there any trick? |
-
No answer for cheaters
-
-
Firstly, you cheated in round 899 div.2. Secondly, I have a legit prove that you tried to cheat during this round.
-
-
3 months ago, # | What is test 7 in Div 1 D :( |
3 months ago, # | After solving Div2 D, I have a strong feeling that D can't be solved by 2000 people itself in Div2, maybe heavy cheating is going on i Think |
3 months ago, # | Is there a randomized solution for D1C? I was choosing an index that was not circled in the answer, the probability of an index X to be that index is >=1/2 so with about 20 chooses I fill find such index. Then I was trying to make an answer for it greedily. |
3 months ago, # | Interesting, but strange solutions for D1CD |
Can someone help me find out, what is wrong with this submission? Div 2B/ 1A: https://codeforces.com/contest/1877/submission/227185346 |
3 months ago, # | Was dvi2E doable with 2sat or am i trolling? |
-
My solution was like this:
If we could find sush uncircled elements such that:
for every uncircled element with value x there is circled element with index x
for every circled element with index i there is uncircled element with value i
Then it would be easy to find a solution
We can also see that this conditions are neccesary Now we just need to add our conditions to 2sat We will have 2n variables Variables i, 1 <= i <= n will be : 0 β if we doesnt circle element with index i 1 β if we circle element with index i Variables i, n < i <= 2 * n will be:
0 β if we circle all elements with value i
1 β if we doesnt circle all elements with value i We can see that adding clauses is easy now
-
How do you express 2. condition with 2-sat clauses?
-
When i is 1 it implies i + n is 1(it means that not every element with value i is circled)
For n < i <= 2 * n
i is 0 implies j is 1 for all j such that a[j] = i (every element with value i is circled)
For 1 <= i <= n
i is 0 implies i + n is 1 (if i is not circled then not every element with value i is circled)
-
Div. 1 C was a strange one, I couldn't find the edge case on which I failed... |
3 months ago, # | Why can't I submit a contest problem now? Is it always like this during system testing? I never tried before. I really want to submit 1E. |
3 months ago, # | It seems that the score distribution of Div. 1 and Div. 2 are accidentally reversed. |
3 months ago, # | The sample is too weak :( |
3 months ago, # | aaa QAQ,i'm firstly loser!!!QAQQQQQQQQQQQQQQQQQQ |
Totally not today's D. Also it seems like that GfG post is only 3 weeks old lol (nvm, more like it's 6 years old) If this problem actually appeared in the I am not saying that someone from the writers stole a problem, I'm wondering how nobody from the round organizers or the testers tried to google something like Sum of maximum elements of all subsets, that's literally the first search answer |
-
The 2 problems are very different though. There are plenty of problems with sum of max element of all subsets, just tat the condition for the subsets are different
-
Everything is relative, but I can't agree with very different
It's obvious that selecting an index is not worse than selecting any of the subsequent indices, so for each we just update the value at that position with max of values on positions that are divisible by with time complexity (another way to notice this is to consider taking an index ).
After this operation the problem is reduced to the one described in the article
Personally for me the condition of the green and black elements felt more like a red herring
-
3 months ago, # | them bu l qua |
Can anyone please give a hack? I get WA on pretest 4 on problem 1C/2E Edit: ignore my last sub please, try this |
-
4 2 3 1 2
Your output: -1 Ans: 2 1 2
-
Did you test my output with my last sub? I realized that it was wrong during the contest but didn't correct it, However My other solution passed this testcase but still got WA on pre 4. Thank you for the test anyways. Any other ideas?
-
3 months ago, # | Any one can elaborate there E approach like will it is related to functional graph kind of think? |
3 months ago, # | why the name effects of anti-pimples for problem D?? |
3 months ago, # | I was not able to submit solution for D while the contest was going on, It showed some error and then it started showing that "same code already has been submitted" So, I thought it will be considered but its not been considered in final standings and the solution was correct when I tried it after system testing. What can be done about this ? |
3 months ago, # | can anyone tell me what is wrong with my solution of the d problem in div 2 , 227195204 |
3 months ago, # | Failed to Notice in D2D, I let if and , which is wrong as I couldn't count the correct number of indices. However, I passed pretest successfully. Why not make pretest stronger? |
3 months ago, # | For Div2 C how to visualize and find formula for k = 2 and k = 3 |
-
if(k==1){ System.out.println(1); }else if(k==2){ if(m<n){ System.out.println(m); } else{ System.out.println(n+m/n-1); } }else if(k==3){ if(m<n){ System.out.println(0); }else{ System.out.println(m-n-(m/n-1)); } }
-
Thank you
-
I made a table for B, maybe you can take a look
std::map<int, int> mp; for(int i = m; i >= 0; i--){ std::set<int> st; int t = i; st.insert(t); for(int j = n; j > 0; --j){ st.insert(t % j); t %= j; } mp[(int)st.size()]++; if(st.size() == k){ std::cerr << i << '\n'; } } for(auto x: mp){ std::cout << x.first << " : " << x.second << '\n'; }
-
-
Video editorial for div2 β A, B, C and D with Code Walkthrough Youtube Video Link |
3 months ago, # | is it just me or does anyone feel like Codeforces is giving less rating points than previously for the same ranks |
3 months ago, # | I didn't participated during the competition, so I participated in the Virtual Participation. But I wonder why the number "265" appears so many times in the examples. |
3 months ago, # | Waiting for the editorial!!!!!! |
3 months ago, # | As for the problem B in div2, my code got Pretests passed during the competition and got ac after the competition, But why does it show that I did not pass problem B ? Is there anything going wrong with the system? |
3 months ago, # | Thank all of you,this is a great contest! |
3 months ago, # | I really like the problemset for this contest :). Thanks a lot to the authors, only complaint is maybe d1b is a little bit boring, but it's still fun. I think my favorite is d1c. |
3 months ago, # | I think div2's E is like a shit, not only without useful examples, but also with a misleading example |
-
Do you play Genshin impact bro.
-
Yes,I do.Genshin Impact is an open-world adventure RPG developed by miHoYo. Set forth on a journey across a fantasy world called Teyvat. In this vast world, explore seven nations, meet a diverse cast of characters with unique personalities and abilities and fight powerful enemies together with them, all on the way during your quest to find your lost sibling and the hidden secret of this land.
-
3 months ago, # | you can find number 265 in 1A's 1B's and 1D's test. |
3 months ago, # | It was a good contest and I have learnt a lot of it and especially b and c were good problems |
3 months ago, # | Attention! Your solution 227183020 for the problem 1877C significantly coincides with solutions hariom01/227149426, 8void/227157830, Amrish_Yadav/227168798, AdS2024/227171397, raushanthakur00/227176995, prathmesh_100/227179845, amirbinirfan/227181906, balkishan09/227182048, YuvrajSinghCharavande/227183020. Such a coincidence is a clear rules violation. i received this mail but the question is case based for 3 cases k=1,2,3 and greater i wrote it in the sequence k>3 for 0 ways and then outputs for the rest. i checked the codes submitted by others as well but i donβt see the complete resemblance also those accounts are far newer then mine. Also i would like to know why problems 1 and b are skipped as well. |
5 minutes ago, # | how to approach the problem 3 in division 2 of this round??please help |
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK