Hi Codeforces!
Keshi, alireza_kaviani and I are delighted to invite you to participate in Codeforces Round #800 (Div. 1) and Codeforces Round #800 (Div. 2).
- Start time: Jun/16/2022 17:35 (Moscow time)
- Duration: $$$120$$$ minutes
- Number of Tasks: $$$6$$$ for both divisions
- Rated range: ($$$-\infty$$$,$$$1899$$$] for Div2, [$$$1900$$$, $$$\infty$$$) for Div1
We are honored to have set the 800th Codeforces round. We wish this wonderful platform all the best along with many other exciting rounds.
Huge thanks to the following people:
antontrygubO_o for his breath-taking coordination.
Our testers Um_nik, errorgorn, Koosha_Mv, irkstepanov, x86-cake, sohsoh, fatemetmhr, Dorost, nor, pooya-shams, Arnch, Kahou and mosaev for testing the round and providing invaluable feedback.
radiohead because we got inspiration from them while coming up with task names.
MikeMirzayanov for the amazing platforms Codeforces and Polygon!
Last but not least, to all the participants of this round!
Thanks to NEAR for supporting this round, details can be found in this post.
We have worked hard to keep the statements clean and the pretests strong!
Please read all of the problems and their notes, enjoy your time and solve as many as you can! Good luck have fun to everyone!
The scoring distributions will be announced later.
UPD: Here are the scoring distributions:
Div. 1: 750 1000 1500 2250 2500 3000
Div. 2: 500 1000 1500 1750 2250 3000
UPD: Editorial is out!
Great contest! you will enjoy it.
BitmaskForces ?
Good luck everyone...Hope everyone performs well :)
lol .. He said Huge thanks to testers for providing
invaluable
feedback.If you dont believe me scroll and check.
invaluable != not valuable
invaluable is actually of stronger positive meaning than valuable, its easier when u understand it as "unable to be valued as it is too precious to be"
i did'nt know ThankYou
don't use past tense with did not, i also did earlier, SAY i did'nt know
ok sir.
Thank me later :)
i think i dont need to.
You do, kindly
Orz
Orz
Orz
Orz
[Deleted]
ratio
Orz
Orz
orz
oml how far is this going
Can't go anymore :(
The debates reached maximal permitted depth, so your message and the message you are replying will be displayed on the same level.
Orz
Yet another great Iranian round :) orz
Orz
Hope everyone can be red in this contest (of course include me).
btw congrats to alireza_kaviani for qualifying in Iran's IOI 2022 team
Manchester is RED , alireza_kaviani :) orz
Manchester is Blue
Codeforces orz
MikeMirzayanov orz
Polygon orz
Orz
Orz
Orz
Orz
ORZ
orz
Orz
Edited: Sorry no orz no orz !
Orz
Orz
Orz
Noo orz!
stO Orz
Paranoid creepy tasks?
Don't worry, no surprises.
Don't worry, there will be no more than $$$10^9+7$$$ suprises.
You don't belong here
You don't belong there
orz
As a tester, problems are great and statements are short.
I encourage you to participate in this round!
You will definitely enjoy this round!
Haha certainly....but sometimes short ones are the real fire ones...looking forward for this round....
Where is translation into russian?
Another div1 with trygub support? It will be fine.
Hope all the best for everyone
Finally, my first Div 1 contest. Yayyyy. Every time I used to fall back to expert just before Div 1 contests.
Have seen you somewhere ... anyways best of luck...
Good luck for everyone!!!
good luck for everyone
good luck man!
ok thx
Um_nik orz
Good luck !?
Naah,it won't help :(
800th round! A great number
WOW! We have crossed 700. ٩ (◕‿◕。) ۶
No hacking ??
All the best everyone!
My first time participating in Div. 1, I am so nervous.
Good luck
how you became expert in your first contest itself??
I thought the base score was 1,500, and I got +167 in my first contest.
Wow, great!! 800 contests, its huge!! Thank you Codeforces❤️
We hope that 800th Codeforces round will be more interesting for all of us.
Hope for the +ve delta in this round
Will this contest be rated?
Rated range: (−∞,1899] for Div2, [1900, ∞) for Div1
I know I won't be able to solve any one of em, still gonna participate..
That's the spirit! Wish you the most of luck! <3
Thanks, I appreciate your kindness.
Yes you are noob
No stool, Sherlock!
And you are an LGM?
And you are tourist?
GAP
Hope I don't go back to being a pupil :/
Same TOT
When someone says orz as a comment

orz
tell newbie what is orz
https://letmegooglethat.com/?q=what%27s+orz%3F
mean move
is an emoticon that represents someone who has fallen over or is bowing down on their knees and perhaps pounding their head on the floor.
The o is the head, the r is the arms and upper torso, and the z is the rest of the body and legs.
orz (thank u)
is it contest?
No, it's a twin contest.
no, it is rated.
orz
Benq When are we seeing you in the action?
I guarantee you will enjoy the contest.
nice
I hope I don't lose points in this game.
I thought so too.
I thought so too too.
I hope so too.
No offence but why does authors tend to hide the score distribution and reveal it just before the contest starts?
is there a hidden strategy out there?(⊙⊙)(☉_☉)(⊙⊙)
Lmao, what does +inf & -inf rating mean !!
infinity, quite literally. If you did not know, negative ratings exist and they are not rated in most rounds (most rounds' rated range begin from 0)
[1900, tourist] for Div1* :v
It should be [1900, tourist].
That time tourist didn't registered.. now registered.
Orz to people that have actually seen his handle fully red
I hope that this contest is nice for all.
I hope we get to the max rating after this round ^_^
Good luck for everyone!!!
Why only two div2 testers?
Eight 100!!!
And his name is Jauun Cenaaa...
Why so many orz comments? Could someone explain, please?
A Hieroglyph.
RIP Score distributions.
When will be the score distribution update? It's just 1 hour 12 minute remaining.
My first contest!!
Not a Doctor Still doing a lot of operations.
Won't say bad round. I liked the Problems though.
I think that this contest isn't good. I can't understand the problems well.
Why so many downvotes !? It's my personal opinion !
Because people didn't like your opinion. I mean that is how this system works. If people don't like your opinion they downvote you. if they like it then they upvote you.
I agree with your opinion!
If this was a Div2 I am a refrigerator. tf.
I don't mind difficult problems but a,b,c are very observation based and took me a lot of time, hence we don't get enough time for interesting problems like D
I dont like this round (my opinion)
I respect the work of autors. Its very cool to do problems for codeforces round. I dont like this types problem. Thats what I meant.
I guess I am just dumb.
Round #800 CLASSIC GREEDY ONE !!!!!!
I didn't expect adhoc tasks :(
I liked problem C. Sample cases were very useful for solving.
I hated it for that reason, but problem was very good . They should'n have provided the 5th sample it was easy to guess then.
The comment is hidden because of too negative feedback, click here to view it
That's kinda funny tbf
How to solve Div 1C?
Reverse the graph and then do something very similar to dijstrak starting from n-1. Notice that at some node, you have a bunch of nodes you can go to and if you know their distances, you can kill some in descending order(so like their effective distance is +0 +1, +2 +3....) and find the optimum of that. Thus, what you can do is to store the current estimates incoming (after reversing) for each node and pick the best (similar to dijstrak) after adding some weights. Then, we process the nodes by current estimate similar to dijstrak. But this may potentially force you to reupdate the whole set everytime you process a node. But, you realise that you only add numbers greater than numbers you add before (since you process nodes in ascending estimates). So, you can just store the best estimate.
Essentially its just do dijstrak with the following modification:
dist[v] = min(dist[v], dist[u] + indeg[v]) indeg[v]--
I still cant really prove why this would be entirely correct though.
For problem D: if the sequence is decinc, there are only at most $$$3$$$ representations of it, that are of interest. For maximum increasing subsequence, you must use all elements except maybe one and if you don't use an element in the increasing sequence, it's always either first or last element.
Note that if the sequence is decinc, then so is all of its subsequences, hence you could kind of make a binary search for each $$$L$$$ on the largest $$$R$$$ such that $$$[L; R)$$$ is decinc.
But my solution failed pretests because it uses binary lifting and needs $$$O(n \log n)$$$ memory. I'm pissed off it doesn't pass.
Now that I think of it, you can probably also do it in $$$O(n)$$$ with two pointers?
I've seen a version of Div1D with answering for whole sequence in a few Polish competitions, so the key observation (that we can build the answer greedily) was known to me (I'm not saying that the rest is correct, last rounds weren't generous for me).
I can write a bit more: assume that we've split the prefix into two sequences (decreasing and increasing) and the next two elements are $$$x$$$ and $$$y$$$, where $$$x$$$ can be appended both to increasing and to decreasing sequence. It turns out, that if $$$x<y$$$, it's optimal to append $$$x$$$ to increasing one. If $$$x>y$$$, it's optimal to append $$$x$$$ to decreasing one.
Approach for Div2C??
Beginning from last non-zero element, iterating backwards, keep adding arr[i], sum must never be >=0, except at Oth element. That was the opeartion about.
i was iterating from backwards and decreasing the current element say a[j](initial array) by k such that it gets equal to m[j](given array) and adding k-1 to a[j-1] lastly i check that array is equal or not alongwith my pointer is on the first element or not this approach is giving wrong answer
note that last non-zero element can't be negative, but your approach may give Yes.
160850010. I did the same thing. This might help
Extremely thankful!
let j = position of last non-zero number (1-indexed)
There must be no prefix sum of length i(0<i<j) with sum <= 0
A[j] must be negative and total sum of array A = 0
Div2B was hard -_-
maybe you are just paranoid
Can anyone make me understand the div2 problem A statement , please, I am really confused how the define prefix here and minimum possible creepiness
Yeah problem statement was not clear But prefix means abs(count(1s) — count(0s)) till that index eg: 0 1 0 0 1 pref 0 -> has 1 0s and 0 1s so its abs(1-0) — 0 Similarly till 1 to 4 i.e index 0 to 3 more formally 1's count = 1 and 0s count =3 so absdiff = (1-3) = 2 But since we need to minimize creepiness we need to do alternate 1s and 0s so they can cancel each other at certain prefix and abs diff = 0
for every prefix there will be a creepiness. out of all the creepiness of every prefix, we will have to take the maximum creepiness. now this maximum creepiness should be minimum.
form the testcase a=3 and b=7. this means there are 3 0's and 7 1's
there can be multiple answer to this, but lets take the testcase answer: 0001111
now the prefixes for there are: (beside them i will write the creepiness(c)) [c= abs(a-b)]
0 : a=1, b=0, c=1 00 : a=2, b=0, c=2 000 : a=3, b=0, c=3 0001 : a=3, b=1, c=2 00011 : a=3, b=2, c=1 000111 : a=3, b=3, c=0 0001111 : a=3, b=4, c=1
out of all the prefixes, the max creepiness is 3.
in this example, no matter how you arrange the 0's and 1's, you maximum creepiness will never be less than 3.
but this not how you should arrange your 0 and 1. You should first alternatively arrange them and then if there are some left from either just 1 or 0, just print all the remaining of them.
I'll suffer from PTSD from now on for string problems :(
Post Traumatic String Disorder
what's the solution for div1A? I have no idea why I got AC
Hey, Can I ask you, As a div 1 participant how was Div1B?
actually pretty simple problem on dp on trees
Can you please explain your solution, or suggest some similar dp on trees problems.
I don't know if i am eligible to explain something to CM, but this is how I solved.
PS: We also need to check if at some point right[i] becomes zero then all the array elements from that index must be zero, since we dont move towards right anymore.
oh, I understood, thanks! not bad problem though
tox1c_kid got trolled
It's funny that I solved C faster than B and solved B faster than A :D
first time solving A,B,C and D, even though I toke 14 mins in problem A, I hope I get specialist.
Do you have a small test case that fails this simple and wrong solution for 1E?
I also had the same idea, but here is the problem: It might be better to take the right maximum and then the left maximum afterwards.
test case:
5
4 3 5 1 2
The min for 4, 3, 1, 2 is clearly 1. But the min for the 5 would be 3. However, we can take right maximum and then left: 5 -> 2 -> 0. So answer is actually 1+1+2+1+1 = 6 instead of 7.
My C shouldn't have passed... caught the countercase too late though, so FST likely.
B... doable, but I forgot I was counting bad spans which can just extend to the beginning because they're already bad.
edit: facepalm for not knowing how my solve was correct...
1693C - Keshi in Search of AmShZ is the problem of the year.
Disagree, C was standard imo, for example 102341H - Hypno is very similar, but a bit harder.
D, E and F were rather nice, a bit of AtCoderForces spirit, but still way better than most AGCs.
My bad, I had never seen anything similar to C.
Nope, not your bad, it's just your opinion versus mine. The fact that for you it was good and interesting can only be a plus for the problem. :P
Character Development.
wow, it's an honor.
Problems were interesting.
So hard..... I can not solve (Div 1. C)1693C - Keshi in Search of AmShZ, I thought topological sorting + DP may work, but what if the graph has a loop and is not a DAG?`
`
you run a djikstra-like algorithm on the reversed graph. In each iteration, my solution has an invariant that the nodes that have been popped from the set have the smallest values of $$$dp[u]$$$, where $$$dp[u]$$$ is the minimal cost required if one starts from node $$$u$$$ and goes to node $$$n$$$. We remove edges only when we are at the node from which the edge emanates (goes out). Then you can see how a djikstra-like algorithm always maintains this invariant, and hence answer is $$$dp[1]$$$.
details: 160892338
I appreciate it, I think I do not understand the idea of djikstra totally, it is time to take my DS book up again.
Sadly, I may get a down rank.
D1C is amazing and suitable for commemorable 800th round, thanks!
Try dijkstra. This is the largest hint.
I hope to reach expert next round :( :(
rainboy orz on astonishing participation! He won't become a GM after this contest but he really deserved it. This strategy of solving the problems starting with the harder ones is really not that bad, especially for educational purposes.
chadboy
The best round recently I think! Thank the author!
small feedback: A is kinda cool, B&C both too standart IMO
Not sure about the complexity of "dive" function in my solution to D: 160848374. If anybody wants to try to create the test were the complexity is worse, you're welcome (don't know if it's correct or not).
I think I did the same thing, guessing that it would work (somehow it did). I would also like to see a proof of why this type of memoization runs in linear time.
Yeah. I’m doing more stuff, but I can believe that the transition is correct.
I am able to solve only problem A.
Glad to see your persistence, try our best to prepare for the next round!
try upsolving at least B before looking at solution, its not difficult. I always try to solve at least one more problem after the contest
I am able to solve b but in contest unable to solve it.
see https://codeforces.com/blog/entry/103952?#comment-923384
UPD: why downvotes ? I simply removed my original post
div 2 B was little tricky compared to c
may be c should have been swapped with b
I still didn't get why for third example case, namely string "100" the answer is 4. I can get 5 paranoid strings:
100 itself is paranoid, you can first collapse
Also with same logic 10 is paranoid too
But correct answer is 4. Where I'm wrong?
100 is not a paranoid , because we cannot convert 100 to a either 0 or 1 as given in question we have 2 types of operation 1. any substring 10 can be converted to 0 2. any substring 01 can be converted to 1 so f(100, [s1, s2] ) would be -> 00 by operation 1 and now we cannot do any operation at 00
is "wrong answer jury had better answer" different from "wrong answer expected ,found"?
It's 2 different types of problems: "jury" thingy appears where you have to calculate a minimum or maximum answer for example and at some point there is a possibility to have a better answer than yours, but "expected" simply stands for a wrong answer.
Thanks for the round, Div1 pC was really interesting!
What was the sol for Div2 C?
start from right most and think of total left and right moves to get desired, and compare with the first value
I solved this problem using RBS (Regular Bracket Sequence) pattern. If you consider the positive numbers as the number of open brackets and the negative numbers as the number of closing brackets, you will see "If the total sequence is regular and it's closed then the answer is yes".
So you will get Yes for ( ()()() ) or ((())) or ( ( () ((())) ) ). But if the bracket is like this ()()() then it's no because in this case you can't get back to the first index.
oh boi!! you're a genius
Wow, Your analogy is interesting. This is a different way to think of problem.
this is really a great intuitive way to see things! Thanks for sharing it
If at any index < last index prefix sum is <= 0 || total sum != 0 then ans is no
here last index is index of last non zero element.
Take care of few edge cases such as all zero elements
Great contest. The problemset was amazing and so fun to solve. Enjoyed this contest so much.
I think the problem setter is a Radiohead fan. Some of the problem title is similar to Radiohead's song title . Or its just a coincidence .
Yeah it says in the announcement.
oops i missed that.
very good and balanced round + interesting problems. Though I FSTed on div2c but was a silly mistake.
Overall thanks for the amazing round
whats fst??
Failed System Testing
good to know the lingos XD thanks
Enjoyable contest <3 ,, thanks author Fastest problem rating distribution .........
How to solve Div2 D problem?
do DFS on the tree.
if the node children returned a number which is greater than or equal lv, just return the min of the returned value of the children and the rv
if it is less than the lv, you need to make another operation to fix this issue, so you will increase sol by one, then you will need to return rv.
But how do you prove that the configurations doesn't matter?
In the sense , say a node has value 5.. 5 can be written as [1,1,3] , [1,2,2] and so on. But in your solution , you just see the min(sum, Ri).
Why does your solution work? Proof?
I can't understand what you mean by configuration and why there are 3 numbers in your examples.
I am not good at writing formal mathematical proofs, but I will try to proof it logically.
The current node doesn't care how many nodes under it, it only cares about the maximum value they all need, because it is the maximum value I can give to the current node, I can decrease it if I want, but I cannot increase it without an additional operation.
But notice that the sum of all the child nodes values may be greater than Rv, so I take the min of them
Can anyone tell the testcase for which my submission is failing (Div2C):- Submission
You can use this app to get more samples (stress testing is not working for unknown reasons): https://cfstress.com/test/1694/c/
logic is right, just use long instead of int for sum.
luck maatters much in life
Finally going to be pupil !!!
I want to prove that other than the similarity in the code in question A Also I got Ac before him/her in question B
can someone tell me why i got tle'd in this submission https://codeforces.com/contest/1694/submission/160921292 Thank you
Pass vector<pair<int,int>>range by reference to dfs function, also use long long for sum
Thank you
For Problem A — Directional Increase , Can someone please check what edge case am i missing — https://codeforces.com/contest/1693/submission/161166279
no try to debug yourself.
Quality comments