Hello / Selamat sejahtera / 你好 Codeforces! ^.=.^
We, CSQ31, Evirir, and YouKn0wWho, are excited to invite you to Codeforces Round 994 (Div. 2) on Dec/20/2024 17:35 (Moscow time)!
In this round, you will learn more about Evirir the dragon and help (or stop) them as they wreak havoc and escape from a wizard.
You will solve $$$6$$$ problems in $$$2$$$ hours.
The score distribution is $$$500 - 750 - 1000 - 1750 - 2250 - 2750$$$.
There will be at least one interactive problem, so please read the guide for interactive problems if you are unfamiliar with them.
We would like to thank everyone who made this round possible:
- Kaey for coordinating the round, coming up with ideas and solutions, and helping with preparation;
- Alexdat2000 for translating the problem statements to Russian;
- A_G, Alpha_Q, Darkeld, ducksaysquack, francesco, JOliva, LMeyling, OMARB, shaili17, Tainel, and whiitex for testing our round and providing useful feedback, praises, and flames;
- You for trying out our problems; and
- MikeMirzayanov for the amazing Codeforces and Polygon platforms that support contests beyond Codeforces contests.
Fun fact: As far as we know, this is the first round by Malaysians since 2020 (last being Codeforces Global Round 10)!
UPD: The score distribution has been added.
UPD 2: Editorial
UPD 3: Congratulations to the Top 5!
Div. 2:
Div. 1 + 2:
nice
Do you really think i will solve them?
Hoping for a fun contest!
hope to reach Specialist!)
Same
Same
same
not same haha
finally, i did it
Congratulations
thanks)
hope to reach pupil :(
same ;p
same!
same
same
frist connemt :D
:'(
Well you see, the question of "who asked?" is simply a paradox. Since by asking "who asked?", you are implying that people need to be asked before speaking. However following that logic, you would have needed to have someone grant you permission to say that, because who asked you to say "who asked?" ? Exactly, nobody did, and nobody can ask anyone to give them permission to give you permission because no one asked them. And this perpetual loop never ends, creating a paradox.
Created by @veryhungrydinosaur
Who asked?
Who asked you to say "Who asked?" ?
Who asked?
hope you all get greens give your best with best wishes
Don't curse me bro :(
orz Evirir
finally a contest with interactive, orz Evirir
don't make C as interactive make D or E or F
Problem G will not be interactive. Probably because there will be no problem G.
https://www.youtube.com/watch?v=dQw4w9WgXcQ
May you get itch on your hand and never find the right spot.
wdym, if there is no problem G then the proposition "Problem G of this contest is interactive" is vacuously true 🤓
Studying first 2 discrete mathematics lectures for final exams be like:
🤓
how many interactives have you solved ever?
a big Zero
so then why do you think your opinion is relevant in any way? solve a few and then you will see that they are not bad at all.
can you suggest some easier problems to start?
https://codeforces.me/contest/1934/problem/C this one isnt the easiest, but its the problem i used as an introduction to interactives, also this one https://codeforces.me/contest/1520/problem/F1
https://codeforces.me/contest/1999/problem/G1 and this one is great as well
i will try them
and I've got to tell you that interactive is so boring.
Happy?
yes
Interactive problems are fun to solve. Isn't it?
Only if you are able to solve it.
Agreed
malaysian round lesgo
Hope no negative delta this time.
AAT, I really enjoyed the problems: it’s well-balanced and has something for everyone. Hope you all have fun solving it, too. GL orzz
judging by the drawing, this is going to be a banger [fire emoji lol]
the frog is so cute...oh! its a dragon,my bad
LOL☠️☠️
Let's go Malaysia
rawr
will not participate if interactive problem is A-C, sorry
What can we do for being a tester.
Eating delicious points!!!
orz CSQ31 orz Evirir rawr >////<
Malaysia let's go!!! Hopefully I get pupil after this contest.
Score distributions??
As a participant, i'm afraid of interactive problems
Cute dragon.
The FBI told me this round will indeed have problems.
You will solve 6 problems in 2 hours.
Tks!Really? Meoww~~~~~~~~
Expected score distribution ?? anyone
Wait... 6 problems and 6 dragon balls? Are we summoning Shenron or debugging our way to a wish?
voila!
dont make interactive problem in A-C
Shield fan
dragon ball fan
real
Why not?
Tahun baru kehidupan mu menjadi lebih baik
hope i will be able to solve 2 of them
were you? idk man, earlier i could atleast solve 2, now i cant even solve the second prob lol. ig imma noob. gotta grind frfr.
It's almost time guys,give us the score distribution.
beautiful
Chill guys, Evirir is busy with New year's shopping. He'll add score distribution soon :)
Score distributions?
I guess 4th problem will be interactive or any easy 3rd problem as interactive
my guess 5th. let's see :p
SpeedForces incoming !!
MexForces
Is E binary search on k? If yes, how?
I am wondering the same question. I tried multiple ways, I mean n has a constraint of 2^30 and there are 33 queries so there must be some sort of way to binary search on answer.
Yes, its binary search.
Lets first split the array into 4 equal sized ranges. This is clearly possible since $$$n$$$ is a power of $$$2$$$ and at least $$$4$$$.
If we queried these 4 ranges, we would either get back:
3 "0"s and 1 "1", indicating that 1 represents the range with the hidden value, and thereby $$$\frac{n}{4} \lt k$$$. In this case, we binary search on the size of the range $$$[l, r]$$$, always ensuring it completely contains the range which returned $$$1$$$. Since this range will always contain the hidden value, the smallest size where the value becomes $$$0$$$ is your answer for $$$k$$$.
3 "1"s and 1 "0", indicating that 0 represents the range with the hidden value, and thereby $$$\frac{n}{4} \geq k$$$. In this case, we binary search on the size of the range $$$[l, r]$$$, always ensuring it remains completely within any range which returned $$$1$$$. Since this range will never contain the hidden value, the smallest size where the value becomes $$$1$$$ is your answer for $$$k$$$.
This naively takes $$$4$$$ queries for the first part + $$$30$$$ for the binary search which is $$$1$$$ too much. But we can notice that the result for the 4th segment can be uniquely obtained from the query results for the first 3 segments, reducing our total to $$$33$$$ queries.
Code — 297544715
Nice problem, thanks
Nice problem and interesting solution!
During the contest, I tried to split the array into $$$2$$$ equal sized ranges, then I was struggling with how to determine whether the return value is case $$$s(l, r)$$$ or case $$$1-s(l, r)$$$.
I did not notice that by splitting it into $$$4$$$ equal parts, it is possible to identify the return value through counting number of $$$1$$$ and $$$0$$$. This is a really unexpected idea for me.
Thanks for your prompt solution reply!
I tried to first do 3 queries on range [1, n/4], [n/4+1, n/2], [n/2+1, 3*n/4]. That way you can find where the 1 is present and if k is greater or smaller that n/4.
Afterwards ask for [1, n/2] in case k >= n/4. If with that you discover k >= n/2 then you search including the half you know contains the 1, otherwise you search in the half you know it has only 0s. This way you can binary search as the function changes from true to false at a single value which will be k.
I think the idea is right but wasn't able to implement correctly, please let me know if somebody finds any flaws.
I did 3 queries:
with first query I can determine which of [1,n/2] and [n/2+1,n] gives answer 1 (because these two intervals have to give different answers.
the chosen interval [l,r] is divided into two halves [l,m], [m+1,r] and they are queried.
If those two answers are the same: that means [l,r] doesn't contain 1, and we also determine if k is in range [n/4+1, n/2] or [2, n/4].
If the two answers are different: that means the [l,r] contains 1 and k is in range [n/2+1, n].
In all these cases, the remaining part is very simple binary search on k.
Solving D too slow made me fail to return CM, nooooo...
F is cool
Question B's n constraint of 5000 kinda confused me for a bit, for a moment I thought it was brute force, tho it turned out O(n) is enough.
Problem, Problem B.
"Submit code for E": 0:00:09
The submit site done loading: contest over.
Screw me over....
agghhhhh, I solved B and C so slowly :( and just almost solved and implemented D in time.
Slow specialist like us are tend to eat dust from the expert + CM. Time to upsolve and practice some more haha
this contest was a pain in the ass
Yeahhh!! There goes my rating .
2049A - MEX Destruction = 1696B - NIT Destroys the Universe
Solved the latter 2 days back so this was a treat
why'd my go solution for A gives different output on cf?
works fine: https://ideone.com/UYCdmo
doesn't: https://codeforces.me/contest/2049/submission/297496814
MEX FORCES
Is there something wrong with the tests on D? Why did my N^4 solution passed?297536216
It could be TLE on the main tests.
Somehow passed also. Monkalaugh Monkalaugh.
O(N^4) for N^2 == 50 000 and 2.5s sounds like it might actually fit. I might hate myself for not trying that solution... I literally thought about it...
How to C?
do MEX operation as problem said, repeat it 10 times (probably only need 3 times, but I rather 10) and you AC
i cant wrap my head around the q, it requires u to perform mex on values whose values themselves need to be discovered by mex on other values
Fix $$$x$$$ and $$$y$$$, then brute force every other position. You can see that there exists an answer with element value never greater than $$$3$$$.
Can you please elaborate a little bit,i couldn't understand why and how?
Without loss of generality, assume $$$(x, y)$$$ as $$$(1, y-x+1)$$$ (as the array is cyclic).
We'll see that friends should have different value, thus we can fix $$$a_1 = 0$$$ and $$$a_{y-x+1} = 1$$$.
Loop for all $$$i$$$ in range $$$[2, n]$$$ except $$$y-x+1$$$. Initially, $$$a_i = 0$$$. Keep increasing it until the first moment it is not equal to any of its known friends (known = elements that had been set before, that would be anything previous $$$i$$$, $$$1$$$ and $$$y-x+1$$$)
You can also do it without ever using 3, i.e., using elements 0, 1 and 2 only.
If $$$|x - y| = 1$$$, then if $$$n$$$ is odd, print $$$2, 1, 0, 1, 0, ....$$$, and if $$$n$$$ is even, print $$$1, 0, 1, 0, 1, ...$$$. If $$$|x - y| > 1$$$, if the number of dragon between $$$x$$$ to $$$y$$$ and $$$y$$$ to $$$x$$$ is even, then print $$$1, 0, 1, 0, 1, ...$$$, otherwise let $$$a_x = 2$$$, $$$a_{x + 1} = 1$$$, $$$a_{x + 2} = 0$$$, $$$a_{x + 3} = 1$$$, ... (I draw all of those cases and saw the answers LOL).
If there wasn't another condition on x and y, then the trivial solution is
But when there is another condition on x and y (And if they have the same parity), then you will have to make either a[x] or a[y] equal to 2 too. (Note: There is an edge case when n is odd and x == 1, y has the same parity as x, then you will have to make a[1] equal to 2 instead of a[n])
First, think about a simple cycle of size $$$n$$$. If $$$n$$$ is even, $$$[0, 1, 0, 1, \ldots, 0, 1]$$$ is an answer. If $$$n$$$ is odd ($$$n \ge 3$$$), $$$[0, 1, 0, 1, \ldots, 0, 1, 2]$$$ satisfies the condition.
For this problem, there are at most two cycles in the graph, and they share exactly one edge. You can allocate $$$0$$$ and $$$1$$$ to the two vertices the shared edge connects, and do the above for each cycle individually.
How to solve C?
Think graph.
Thank you very much guys for the round. Much appreciated.
hopes shattered!
Ok, I'm absolutely stumped by WA on test 1 in E.
My submission correctly guesses "5" for the first sample case when run in Codeforces custom test and locally (tried compiling with both -g and -O2) but incorrectly guesses "4" when submitted.
All queries are small enough to safely verify by hand ((1, 2) --> 0, (3, 4) --> 0 and (5, 6) --> 1) or the responses are present in the sample ((4, 8) --> 1 and (3, 8) --> 0) so I doubt that's the cause of the issue.
I also don't see any obvious undefined behavior in the code:
Can someone help identify the undefined behavior (or mistake in my query responses) that are causing the difference?
Edit: I know there is a different bug in the code for the
if(cnt_ones == 3) {
block, but the samples don't run it.For $$$k = 5$$$, the response for $$$(4, 8)$$$ would be $$$0$$$ since range contains $$$1$$$ $$$($$$at $$$6)$$$ and length $$$= 5$$$ is atleast $$$k$$$.
Oh, test case 1 and the sample are different...
I looked at the output of test case 1 and the explanation of the sample even though those clearly make no sense together >.> (using $$$k = 6$$$ for calculations and considering $$$k = 5$$$ output correct lol, my brain was clearly fried today)
losing too much time on ABC sadly, could've have enough for solve 1 more but I can't... maybe next contest :(
Too much usage of mex. Had to try a lot of cases to figure out the pattern in C.
Is there beautiful solution in C? Because my solution is $$$ififififif$$$.
You can break the big cycle down into 2 small cycles defined as (1) in between x and y, and (2) outside x and y. ans[x] = 0, ans[y] = 1. Then, for each cycle, we separately start from y and work through the cycle back to x, just alternating the values being 0 and 1. If we return all the way back to x and find that we placed 0 and 0 adjacent to each other, we make that last-placed value a 2.
I don't know if it's a beautiful solution but here is my solution : 297477253. I know that a[i]<=2, so for each i, I create a set containing 0,1,2 and erase a[i-1], a[i+1], a[x], a[y] if I've already calculated their value, then I take the minimum (I have no proof of why it works but it seems logical).
I have solved with 0,1 only and then use 2 for the x,y cases:
B >> C
I thought B > C too while at it, but when I realize a trick in B it's simple
(I'm on panic af ngl, losing so much time shuffling between B-C, also losing too much unnecessary time on A because I'm late)
I came up with some bs solution for b, what is the easy way to do it?
Brute force :3.
brute force it coz n is small. The idea is work around left bound and right bound of an element
With every p or s, it limits the left/right bound. After that check if l<=r for all and no range is overflow (range of 2 can't contain 3 numbers)
Breh, that's what I did... ig I was just trying to shortcut a check to find if any range was overflowed and thus took too much time instead of being patient.
I too, was panic so bad and losing too much time...
I bet I can solve E with 30 more minutes sadly. (I pick E personally, coz I love interactives)
Also, NOOOO! ... I just realized right now that my implementation of D was all correct except for saying that i = 1, I had to say i = 0. This actually sucks.
?
ugh, ok, I get the error in D2, it's due to LL handling in cpp :(
Ad hoc forces, there goes my rating..
I suck so bad in solving DP problems, can you please share me best dp practice set apart from cses dp a problem/practice set with less no of problems but more to learn... plz
Exactly!! The standard dp is easy to identify but dp when in disguise like this, its becoming impossible for me to identify
Yup exactly, i am thinking to solve 1800 codeforces dp problems from now on then only i will become good in such problems
Can we solve together?
Problem A:
is similar to https://codeforces.me/contest/1696/problem/BCan anyone help me understand B? i tried a brute force approach. 297536174
... soo i took a hashmap where for every 'p' i encounter i check for 1 to i+1 in the right half of the hashmap (from ind+1 to n), if element exists i simply return that array cannot be made and for every 's' i check for 1 to val (val being n-i+1) in the left half (0 to ind) returning false if i find matching element.
(sorry for bad english)
I think it should be this: If there's an S that occurs after a P then you print NO.
b/c everything after the s needs to be [1,2,...] and everything before the p needs to be [1,2,...]. You can't put the #1 in two places.
If there's an S before a P then you are OK. EXCEPT for an edge case where there's a space before the s and a space before the p.
.sp.
is NOsp....
is YES....sp
is YES.Yeah i was wayy to confused in the test case
sp
giving YES and.sp.
giving NO. I understood the reason hence i went for the implementation through indexes, I am still a little confused if there exists more such edge cases. If Yes how do i tackle them? IF no, then If i use your implementation of only checking for 1 edge case.sp.
will it be AC?My implementation checks for more than just
.sp.
by checking if s is at index 0 or p is at index str.size()-1.(First time really using the comment section so I think this is how I link my submission: https://codeforces.me/contest/2049/submission/297512367 I handle the edge case on lines 20-25.)
Edit: (Also heads up, I think the comment I left there (line 22) is wrong so ignore it).
Understood Thank you!
Is D Dijkstra?
It's DP
sauce of your profile pic?
It's an anime called Orb: On the Movements of the Earth. It's about astronomy research in medieval times, similar to Vinland Saga in terms of dark stuff. If you want to watch, don't read anything about it online because there are a lot of spoilers for the first few episodes.
Thanks will keep that in mind
Dijkstra can be used only in cases where the answer is monotonic.
I did Dijkstra correctly, but it's a bit slower than DP.
Your one already crosses O((n*m)^2) using three states and one loop. Its answer is monotonic.
I am talking about two states in which the answer is not monotonic.
Fair, thanks for pointing this out. Can you clarify in what sense the answer is not monotonic here?
I didn't understand, what do you mean by "monotonic"?
It's possible to Dijkstra this but it's essentially encoding the DP transitions as a graph and you get an extra log factor
Can Someone Share Hint or Idea of Question C ?
Someone mentioned it in another comment, but I did the same thing: 1. First find a way to make a valid MEX cycle without the additional constraint of x and y being friends:
if n is even: 0,1,0,1,0,1..
if n is odd: 0,1,0,1,...,2.
e.x.
n = 4 --> [0,1,0,1]
n = 5 --> [0,1,0,1,2].
When you add in the constraint that x and y are friends:
n is even --> check if x and y are already valid (x = 0, y = 1 or vice versa). If not, then make one of them 2.
n is odd --> just rotate the array so x or y is the number 2.
My solution of $$$E$$$:
Note $$$left = ask(1, \frac{n}{2})$$$ and $$$right = ask(\frac{n}{2}+1, n)$$$, we can see exactly one of the following conditions holds:
Then we can choose either $$$[1, m]$$$ or $$$[m, n]$$$ to perform binary search.
Sadly can not implement in time ;)
Feels like this round took a slight difficulty spike compared to usual! Some of the problems required a deeper level of observation and optimization, especially under the time pressure. That being said, it's always satisfying to tackle challenges like these—props to the problem setters for making us think harder! Good luck to everyone still grinding through the problems!
I'm not sure if I should be happy that I solved A or sad that I could only solve A?
Contest How much rating you want to lose?
Me: Yes
You actually gained +1
Weird. Maybe got lucky. I was expecting -50 or more.
Same here. I was expecting a -25 but got a +21
How do you interpret the rating?
Just a guess. Seeing how my rating dropped/increased in previous contests as per my rank.
Screencast of me solving in rust (4k would be ready a bit later)
Is Mass Destruction the reference of A?
wow I didn't even think about it, very nice.
I was thinking of doing this problem a few days ago. Could have saved an hour today!
where is the rating? i can't play fortnite bc i waiting for my first pupil is 3 of 6 enough(i solved B on 4 or 5 attempt)
shit, i already played 3 games with my bro, 2 consecutive victory royals. sorry
yeah my first pupil, goddamn i love all of you guys, now i want to malaysia
Codeforces Hot News!
Wow! Coder chenlinxuan0226 competed in Codeforces Round 994 (Div. 2) and gained -160 rating points taking place 4892
Share it!
Solution for d using recursive dp anyone?
Recursive Solution
Thanks
But we are not natural fruits :(
Too hard question for Div2 A. Hadn't expected this :(
This in regard for the my solution to problem 2049C of this round.
I got a notification regarding the coincidence of the solution. This was due the coincidence of the algorithm used in the problem. I wrote the code myself. Also the style of writing the code matches with my previous submissions.
I request the Codeforces Team to review my submission. Evirir
I received a mail regarding submission of problem c that it matched with some other person's submission but my code is not similar to them only the approach can be same which can be trivial you can view my solution — https://codeforces.me/contest/2049/submission/297535805
I deserve the ratings for this contest. Evirir
Subject: Clarification Regarding Plagiarism Accusation for Problem 2049B in Round 994 (Div 2)[contest:994][problem:2049B]
Dear Codeforces Team,
I hope this message finds you well. I recently received a notification regarding my solution (ID: 297506801) for problem 2049B, stating that it significantly coincides with solutions Keylime/297472936 and tinytroubles/297506801. This notification has deeply concerned me, and I am writing to provide evidence and clarify that I did not engage in plagiarism.
Evidence Supporting My Case: Independent Work:
I worked independently throughout the contest and did not collaborate or share my code with anyone. Submission History:
My submissions demonstrate the evolution of my solution: Incorrect Submission 1: https://codeforces.me/contest/2049/submission/297498579 (submitted at 20:56 UTC+5.5)297498579 Incorrect Submission 2: https://codeforces.me/contest/2049/submission/297500380 (submitted at 20:59 UTC+5.5)297500380 Accepted Submission 3: https://codeforces.me/contest/2049/submission/297506801 (submitted at 21:08 UTC+5.5)297506801 These submissions were made within close time intervals, showing a logical progression in my thought process. Geographical and Logistical Impossibility of Collusion:
I am from India, while the flagged participant Keylime is from South Korea (Chung-Ang University). There is no possibility of communication or collaboration between us during the contest. Coincidence in Logic:
The flagged solution (https://codeforces.me/contest/2049/submission/297472936)[submission:297472936] appears to share similarities with mine. However, given the nature of competitive programming and the brevity of the problem’s solution, it is not uncommon for different participants to independently arrive at similar implementations. Additional Evidence:
If required, I can provide timestamps, drafts, and any other supporting materials to further substantiate my claim of independent work. Request for Re-evaluation: While I understand the importance of plagiarism checks to maintain the integrity of the platform, I believe this coincidence is an unfortunate case of two participants independently arriving at similar solutions. I respectfully request a thorough review of my case, as well as stronger measures to distinguish coincidental overlaps from actual violations.
Thank you for your attention to this matter. Please let me know if additional information is needed. I hope this can be resolved fairly and with due consideration.
Best regards, tinytroubles,tinytroubles ... expecting a change Evirir
This is my own implementation, and I have not shared my code with anyone or used any online tools like ideone. I implemented it entirely locally on my computer and followed my personal template, which I developed myself and use regularly for contests. Below is the template I used:
And here is the full code I submitted for problem B:
I received a message stating that my solution (link) is similar to another participant's solution (link).
The similarity might be due to the simplicity of problem B, which naturally leads to similar approaches among participants. Additionally, I submitted my solution approximately one hour earlier than the flagged solution, which supports that this is a coincidence.
I strictly adhere to Codeforces rules and have not engaged in any behavior that violates them. Please let me know if any further clarification is needed.
Subject: Clarification Regarding Solution Similarity for Problem 2049B
Dear Codeforces Team,
I received a notification regarding the similarity between my solution (ID: 297524944) and others. I would like to provide clarification:
The logic of counting occurrences of p and s in the string and making decisions based on their counts and positions is a straightforward approach to solving this problem.
Many participants might have arrived at similar implementations due to the nature of the problem and the limited complexity of the solution space.
My solution was developed on my local machine without exposure to public platforms.
I used standard techniques, and there was no sharing or reference to external sources during the contest.
I have learnt competative programming from a very popular youtube channel "luv". Here's is the link to his playlist https://youtube.com/playlist?list=PLauivoElc3ggagradg8MfOZreCMmXMmJ-&si=vpQNTKNBhLNGmWFT It is very popular playlist among college students so my variable and coding style may match with others.
I am committed to following Codeforces rules and am happy to provide more details if needed. Please let me know if additional clarification is required.
Thank you for reviewing this matter.
Sincerely, [smerkii]
This in regard for the my solution to problem 2049B(solution-297500190) of this round.
Please check the code as i always use this type of variables in all my submissions before Kindly recheck it for further clarifiation.
Also problem 2049A is also skipped and I haven't got any notification yet.