Hello Codeforces, and happy Nowruz.
It's an honor to announce you that Codeforces Round #406 is going to take place on March 23rd.
I'm the writer of this round and it is gonna be my 6th CF contest (there are still plenty coming...). There are 5 problems and you'll have 120 minutes to solve them.
I'd like to thank keyvankhademi and waterfalls for testing this round, netman and KAN for helping me prepare this round and MikeMirzayanov for awesome platforms of Codeforces and Polygon.
The main characters of this round are going to be Rick and Morty!!!
Scoring will be posted soon.
Problems are sorted by their expected difficulty, but I strictly recommend you to read all the problems.
GL & HF!
P.S: Top IOI 2017 participant in each division (only with handle present in the future IOI handle list) will be rewarded with special Persian souvenirs in Tehran.
UPD: Scoring distribution is: 500, 1000, 1750, 2000, 2500 for Div.2 and 750, 1000, 1500, 2000, 2500 for Div.1
UPD: Editorial is out!
UPD: System test is over, congratulations to the winners.
Div.1 winners are:
Div.2 winners are:
See you next time ;)
amd is back! <3
AMD is an absolute champ in preparing nice interesting and original problems.
Amd's contests are so good. I've never been disappointed with any of his contests. Looking forward to this Thursday.
are you sure then IOI participants has in EACH division?
You would be surprised, but as far as I remember the split was 50 / 50 for those with a Codeforces account.
"I strictly recommend you to read all the problems"
does that related to the difficulty of the upcoming problems???read this
From quite an experience , I believe , the statement wants to convey that C can might turn out to be easier than B :P
For example, you are very good at math and E is math problem which you can solve, but you are solving A-B-C and can't solve D, so you can think if I can't solve D, I won't solve E too and don't reading problem. So, it is good to read all the problems.
Will be using this when code fails system tests :(
Happy Nowruz! I wish everyone that the round was truly festive!
I missed PrinceOfPersia's rounds so much!
(only with handle present in the future IOI handle list). Where's that list?
future
Problems are sorted by their expected difficulty, but I strictly recommend you to read all the problems.
GL & HF!
// What's the output of this code ? :)
compilation error: unexpected token
Luck
"Do ya hear that M-M-Morty? *URP* We're gonna go to a universe where everyone is a character in a programming competition, Morty--"
"I-I, uh, I don't know Rick, that sounds like--"
"A programming competion, Morty! Codeforces, Morty!"
Hope morty doesn't go back to the old shop... :/
Good Luck and Have Fun !!
I hope this comment becomes the reference for all authors who are lazy to write it , and they write GL or HF . so they can copy paste it from here .
GL with that!
i hope there will be nice mromlems today gl hf friends
First of all I apologise to write it here as I am very much new to this.I want to hack a problem which is already accepted.But I can see that the solution is wrong,what to do,Please Help.
maybe ask @PrinceOfPercia
AMD setting the round + Main characters as Rick and Morty. This is going to be good.
do not be so sure until you see the mromlems
A contest about me? thx :D
wowwww im very much excited about the contest ... for giving this contest i will eatless :) hoping for +ve rating change and i love all the contest prepared by PrinceOfPersia ... and i love him too :) his style of blog writing is awesome and he is also awesome... i love codeforces ,,,,, i love MikeMirzayanov and i love alll :) happy coding best of luck for the contest :D
"and I love him too"
What made you change your mind?
I just love codeforces contests
Best theme ever! This is one of the main reasons for why I love competitive programming...
..
Why the hell your characters are soooooooooooooo intresting?! 1-Barney Stinson 2-Mike 3-Rick and Morty all of them are wonderful
Simple answer: because he is PrinceOfPersia.
:|
can someone tell me the full-form of amd please?
Advanced Micro Devices
What??
PrinceOfPersia earlier used to be PrinceOfPersia (he changed his handle on this new year),PrinceOfPersia comes from his real name Amir Mohammad Dehghan
Ok Thanks.
Do i only see that i have last 2nd contest's amount of points instead of amout that should i have now? I mean i have 1021 when i had after last round 1087 and i see everybody have the same issue
Also my submissions from last contest got back themselves
Glad to see my teacher is holding another round, good luck PrinceOfPersia (reply to this comment).
Happy Nowruz everyone) Hope that most will increase their rank
Everybody, who liked this commend will increase his rating))
*no one upvotes and thus your statement is true*
Good thing CodeForces doesn't have verdict "Not Acceptable", else this round will be full of Error 406: Not Acceptable.
It's my birthday contest !! thanks PrinceOfPersia :D
Happy birthday :-)
happy birthday
Guys, better prepare robust version of Heavy-Light Decomposition. Afair on 3 out of 5 PrinceOfPersia's contests E required it xD.
Thanks, I will Unregister!!!
Yeah, possibility of Div1E being HLD is a perfectly valid reason for greens to unregister ;p.
I understand Sarcasm.Thanks
If E is HLD,then Accordingly all lower problems like D will be of PersistenSe segTree amd c will be of Sqrt decomposition and b will be of Dynamic programming with bitmasking and A will be of Maximal fLow and minimum cut in graph and Div2B will be from suffix trie and then DIV2a will be Unknown theorems on NUmber theory .So,I said I will Unregister
That's a pretty good and valid point.
Thank You,P_Nyagolov
Guys I have found a genius at sarcasm. Just take my like.
Funny fact: in Round #362 problem E was not a hardest problem, but it was indeed a HLD-problem. So, if a problem on HLD appears, it will apparently be the problem E, no matter how many problems in the contest there are.
On last Petrozavodsk I used HLD once and it was also problem E (E2) :D. Apparently it was second easiest problem that day xD.
who likes inception?
Nice try to increase contribution. Haha
fact : PrinceOfPersia is a gay prince and he's trans.
So?
Amirp78 the only thing we all know here is sir PrinceOfPersia is a great coder and motivation of all of us . His problemsetting is awesome :) and his contest are always interesting , so focus on that fact !!! :)
Hi, Prince)
mrims of persia always very nice mromlems, looking forward to the round 406, good luck
Me when the competition starts (better watch out!)
Aww, you look so cute. Haha
vpsingh you are so cute awwww :) :P
Scoring distribution?
I didn't know the theme was Eminem too
Hacking page does not load.
EM fan eh ?
Did anybody notice the names of the problems...they are the names of eminem's songs too.
Nice taste PrinceOfPersia.
:)
Very long queues.
Is there a long hack queue? My hack has been in queue for almost 5 minutes now
This is exactly how I read the problem statements to understand the whole meanings.
If suppose somebody program is write but would terminate before considering all the inputs would it be a valid program or not?
All that matters is that your output is correct, it is not necessary to take the entire input.
It could be better if there were explanations for the examples in Div 2 problem C. It is possible to understand it ambiguously.
Systests of A will make many people sad (me too) :'(
Like almost everyone after the contest
Div 2 B and C are so ambiguous. There should be more explanation rather than what we had.
Strongly agree with C.
I do really like problem C xD good job PrinceOfPersia
PrinceOfPersia right now.
How to solve C? My idea is to do dynamic programming with 3 state [position][cycle_passed][turn], with O(k) transition. This gives the right answer, however since cycle_passed could exceed 70, my solution got TLE. Am I on the right track here?
It needs only position and turn(0 or 1), nothing else.
Wouldn't the graph be cyclic? and dp only works on DAG right?
With DFS, you could do on graphs that are not DAG either.
I used a dp approach too, conf[player][pos] = 1 if player can win if he moves first from pos, 2 if he loses, 0 if it-s a loop. I made a dfs(player,pos) to find the answer for the current configuration but I'm not sure it will pass the main tests because of the complexity . It became a little complicated when taking care of the loops so I had to use some extra time to verify those.
What are the hack cases for problem 2 divB
I hacked two people with this: 5 1 10 4 4 4 4 4 4 4 4 4 4
correct output is YES
I hacked codes with this case : 4 1 2 1 1
Answer should be YES
I hacked 3 with
2 1
2 -1 -1
Applause Great problems! Thank you, man!
on div2b, why no runtime error for negative values on this solution?
Unsuccessful Hack case
Could you show the whole code?
sure: submission
it received WA on systest, but I was wondering why the hack didn't pass
If you add
cout << ok << " " << v << endl;
to the beginning of code: You get0x554ae0 0x4f3040
. That means thatok
was placed afterv
(exactlyv + 100008 = ok
), so in factok[-1000]
makes sense because it meansv[100008 - 1000]
(Don't have any idea why 100008 and not 100005, that's some compiler stuff).But generally you could get a Succesful hack by this test:
He wouldn't clear
ok[10]
after first group, so he will say "NO" after checking 2nd group and finding that there are two elements with absolute value of 10. But right answer is of course "YES".Also this code doesn't check multiple occurrences of the same element. So
will also have "NO" answer, but the right answer is "YES".
I see, so it doesn't give RE only because that memory region is luckily located within the program scope. Well, at least it didn't pass the systest. Thanks for the clarification, it was very helpful!
Whats the hack for div 2 A?
Try this:
Whats the answer for it?
-1 of course :)
1 2 1 2
10 5 10 7 OUTPUT : -1 . P.S.: I used it twice with affirmative .
I found 2 hack cases:
1 1 1 1 (because of not checking b == d)
1 1 1 2
10000 1 2 -3 -3
So many fell to this single test in div 2 B :-P..
Was it possible to solve Div2.D on Python? I tried all my best, and solution is very simple, but Timeout on pretest 8...
I couldn't really understand the statements. I read problem A like 5 times.
i read it like 20 times til i understand it
I guess he meant Div. 1 A .
I can't still figure out what I should do. Can somebody explain the statement to me? TT
they are moving the same monster alternatively, I read it more than 10 time to figure that out :(
in simplified version, you and i takes turn alternately and choose some number from our set
my set = {4,3} your set = {2,5,3}
let x be the initial position of the monster and i were about to move first
your task is not to make the monster went to the blackhole, and my task is to do so. for example N = 5 and x = 2, and i choose to move 4 steps ahead which makes the x = 1 (circular) then i win, in other case i can move 3 steps which makes the x = 5 and you takes the turn to make sure i can't make the monster into the blackhole
Well you have an infinite game, you have a position and turn. In your turn you take any of your numbers and change position into (position + chosen_number) % n. If you got into 0 -- you win.
I think problem E was just a persistent segment tree .Let A be the original array. Make a persistent segment tree B such that position j of the i'th version is 1 if there is no value equal to A[j] between A[i],A[i+1],....,A[j-1]. Once we have this we can do a greedy construction, because we can find the farthest possible endpoint for the next segment in time log(n).
Is this the intended solution?
B was easier than A
B was not easier, A was tricky.
I don't think so seeing the number of WAs :P
I thought this before seeing the main tests. After seeing the main test... well things changed.
Just 10 more seconds ... (and a faster Internet)
Pretty nice contest (although I failed).
B was really nice but I didn't like A.
On C can I coded a solution (which I thought was and I still think so) the idea was that you change the answer at most when you change the K. Also the answers are decreasing so we can do a divide and conquer with at most times computing/doing the O(N) solution for fixed K. Can someone provide a test case which fails that, because it TLEd?
Also how to solve D?
Is O(n * log23(n)) the intended complexity for C?
Nope
Then can you give me some hint how to improve this? I used binary search + Persistent IT.
Greedily do for K = 1 — 1000 in O(n). Now notice that for K > 1000, answer will be <= 100.
Binary search on the range to get answers that lie b/w x for x from 100 to 1.
For a single x it will take at max O(logn*100*logn*logn) This passes for me in < 1 sec
Yes I done on the similar way.
First I found article where I read problem with amount of distinct numbers online in O(log n) per query and used existing code. Saw it is not enough to pass testcases, so I calculated first sqrt(N) values before binary search :)
Other time at the round I spent in reading first problem :D
my solution is n^2, although I don't know if it a solution quite yet.
I got TL8 with O(n log^3 n)
i think it was very hard round for DIV2 , am i right or not ?
True but there was a good hack opportunity in div 2 B to keep us occupied :-P
it was all about hacks if your room has people to hack you would get high score
right
Hard .
I tried div1 C O(n * sqrt(n)) but it has TLE. Hahaha....
try: const = 2500
I hope 2*10^4 dfs in problem D will fail? In other case I don't understand why it's D. I decided to look at the submitted solutions and it made me sad.
6848 ms!!! Great! Awesome problem...
Awesome problem!
I'm sorry, our best naive solution worked in 14s. I can't find any counter-test for jqdai0815's solution :-(
He just compressed dfs-es in one in order to jump less over the memory. Actually, that's the usual problem with solutions like O(n*log^10).
Yeah, more awesome because so far it is the only accepted solution.
harder than usual but problems are so nice!
We need Nicolas Cage from National Treasure to figure out the problems' statements :( . I read the statements many times to understand the problems :(
The Russian statements look much like a result of some automatic translation: the order of words is as in English, and sometimes the meaning is messed up, too. Still possible to understand, but English version looks more readable to me. Looked way better when Codeforces had staff dedicated to translating the statements, like Delinur.
There should be no Russian at all. Authors should just focus on English. Quite often there was a reverse situation when native Russian speakers didn't care enough for good english statements.
The whole codeforces.ru should be translated into english and removed.
https://github.com/Codeforces
fork and create your own CF with blackjack and what you want))
The problems are too hard to understand.Could you make the problems become shorter,it is unfair to poor English men...like me
can't figure out why my solution 25749847 for B is failing. could anyone please have a look.
you are using break without reading the whole line..
Are all round prepared by PrinceOfPersia have a hard Div 1 A? Or am I too weak?
His last contest has pretty easy Div1-A. All other problem though...
Test Case 24?
This question is so weird.
Try this test case : 1000 1 2 -4 -4
Thanks
Wait, what? It is said that noone can join the group more than once.
Oh god. I got it. I should have read the text better.
no it isn't
Ricks and Mortys have registered online in these groups. So, a person can have joined a group more than once (developer of this website hadn't considered this possibility).
Thanks. I've read "can't"
Fastest System Test ever :'D
there was nothing to be tested :V
WHat is the proof Of DIV2 A ? I cant guess the impossible (-1) case . When it will be impossible ? And whats the proof ?
if both guys from same planet are in the same group then that group is not the required group as both from the same planet can't be traitor at the same time
Sorry I mistakenly read DIV2 B .
For example:
a = 2, b = 1, c = 4, d = 4.
We are adding even number to odd number, so it will be odd number, but c and d are even, their sum will be even to.
b + n * a = d + m * c
therfore :- a * n + (-c) * m = (d — b)
this can be solved using extended gcd. if (d — b) % gcd(a, c) != 0 then answer is -1.
I tried Bezout's Identity for Div2A . But it failed....can anyone correct me.
Also, I can't think of when would it be -1.
see this
That moment when you get div. 2 problem A wrong in system test
you are not alone
I felt so silly lol
Gotta be more careful next time :)
pretty balanced
It isn't a good idea to make Div1 A so difficult.
795 users registered for this Div1 round but only 343 made at least one submission.
Please say this to topcoder admins too! :P
This time lots of Hacks & System failures! :p
Please Can someone tell why i got WA in Prob B ?
http://codeforces.me/contest/787/submission/25753050
///
I got accepted.
same number can come...
Try this
4 1 2 1 1
Output should be YES
Try this test case:
1 1 2 1 1
. The answer is YES.Thank you all guys !! :)
So easy div2 B problem, but so difficult-to-understand problem statement.
Puzzle: Name of all problems are names of Eminem songs, except for Div.1 E. Eminem has no song named ALT, so what is the story behind ALT!?
Because Encore (mentioned in the statement) is an Album not a Song?
Okay, Encore is an album, what is ALT?
ALT.music.eminem
Alternate? idk :P
This?
I know the answer) And this is "Ass like that" :D
Exactly ;)
Could you guys help me with why I got Div2B wrong?
http://codeforces.me/contest/787/submission/25748568
I think I misunderstood something.
you should clear s after push_back
DIV2 B- not afraid . I solved this problem , One submission with break getting WA on test 10 but test case is too long so cant guess the bug — > WA on test 10 , Submission With break statement .
Another same submission got AC where i just cut the break statement -> GOT AC submission without break statement .
Can not find any short test case which will give the WA for first code .
Here is the diifference : Difference
Can you check this test? 10 2 3 5 -5 -5 1 3
b should be 1500 and c 1000
PrinceOfPersia EVEN A BLUE CODER OR CYAN CODER CAN MAKE CONTEST WITH UNIFORMITY IN PROBLEMS LEVELS THAN THIS CONTEST.FOR EXAMPLE,TAKE SOME PREVIOUS CONTESTS
Gaand fat gai kya? :D
Beautiful arts) I was enjoying this contest)
My code of div2B WA vs AC after contest
My Code failed on #59. Can someone explain me how this passed 58 test cases ! !!
My best experience in CF.... I will remember it :'(
Is it rated?
Ofcourse!
please i want to know something: i made this submission during the contest: http://codeforces.me/contest/787/submission/25739022 and then i made another submission in the same problem because there was something i was not sure of, the other submission was hacked, and the first submission above was counted hacked also as you see in the submission link
after the contest i submitted the above submission again exactly and it is accepeted: http://codeforces.me/contest/787/submission/25754392
is this normal ?
I'd guess a yes
It is probably because only the last one that passed all the pretests count for the contest, so your correct submission during the contests technically did not count
why.... http://codeforces.me/contest/787/submission/25746564
A positive rating change means absolutely nothing when u know u have not done well at all in the contest. :(
Hello, I think I found a mistake in system tests in task B. Time limit is 2s and I've found the test in which solution has been executing for 2.8s but system test said that it is valid.
http://codeforces.me/contest/787/submission/25744252 the test is :
10000 1
10000 1 1 1 1 1 1 1 1... 1
2.8s on your machine maybe, probably without -O2
Custom Invocation 46ms
I was able to lock my solution after being hacked. HOW?
wasn't the character next to Rick in div1 D (Rap God) Pearl from Steven Universe?
I've got a mysterious submission issue;
Here's my code:
http://codeforces.me/contest/786/submission/29148189
It meets a RTE with a exit code which usually means array/vector visit out of range.
But my vs2017 report nothing and runs well, and I had never disable runtime warnings.
So I submited it in MS C++.
The first time it runs and I've got a minor mistake.
before correction
after I corrected it with only one line, it cannot even compile.
after correction
And the bs reason
I got really frustrated. Can someone help? What's going on?