Hi community,
I'm glad to invite you to my first contest, Codeforces Round #652 (Div. 2) which will be held at Jun/23/2020 17:05 (Moscow time) ($$$\text{notice the unusual time}$$$). The problems are mainly prepared and invented by me. The round is rated for participants with rating strictly less than $$$2100$$$, others are able to take part in the round out of competition. You will be given $$$2$$$ $$$\text{hours}$$$ to solve $$$6$$$ $$$\text{problems}$$$.
Firstly I'd like to thank adedalic for coordinating and reviewing the round, as well as helping with many different things.
I'd like to thank antontrygubO_o, physics0523, McDic, Ashishgup, dannyboy20031204, Kuzey, SinaSahabi, FieryPhoenix, ma_da_fa_ka, ITDOI, AM_I_Learning, awoo, lynmisakura, JustasLe and ArimeZ for testing the round and giving valuable feedback.
Also I'd like to thank coauthors, amiralisalimi, AS.82 and davooddkareshki for helping me with inventing and choosing the problems.
Finally, thanks to MikeMirzayanov for very nice and convenient Codeforces and Polygon platforms.
I wish you all will find the problems interesting, thank you for participating, and good luck!
$$$\text{Scoring distribution : } \; 500 ~- 1000 ~- 1500 ~- 2000 ~- 2500 ~- 3000$$$
$$$\textbf{UPD}$$$ : Editorial is out
An Iranian round after a long time .....
Thanks for your hard work.
Thanks, we'll see more Iranian rounds from now. :]
What matters to us is a codeforces round, whether it's Indian/Iranian/else. We love codeforces
Just some contribution spamming
Its true. But these comments are mostly about finding someone you can relate to as the problem setter among the vast CF users. So there is no harm done.
True man
Can't agree more with you nik. All that matters is the new question set : )
Deleted
please focus on the rounds rather than who sets the problem that's none of our business we are just bunch of human beings that share the same love for coding !!
Deleted
so what lol just because I have a country name in my username doesn't mean I am those type of people who cares more about ethnicity or nationality when it comes to enjoying solving problems on codeforces !!
Deleted
I am an atheist.Can i participate in this round?
You welcome.
LoL.
Congrats! For these downvotes :p
I hope that your question is not a way to make fun of author's faith. Cause I'm smelling something like that
Really like to discuss the down voters. Why someone asks something like that? Can you see any kind of religion constraints in announcement or in CodeForces rules? Then let me know too!
You got downvotes because of a totally off-topic comment.
Was the original comment on-topic?
He got downvotes because he misinterpreted the essence of the question which boils down to the relevance of expression of faith in the contest announcement.
?
Like, why are you answering yourself
Guys may you tell me why someone should ask such question. Just your opinion. I mean the abhisar1414 guy
Reading it the 7th time. I don't understand what you are saying.
He mentioned formal compulsories in Iran. And just to remind him, you can find formal compulsories anywhere, I just made an example of a formal compulsory in America, the SAINT OF LIBERTY. I felt responsable to make things clear. Hope you get it.
And also I'm sure that the author has not followed any compulsories. Just personal beliefs.
Can't you figure out which comment answers what?
They're on the same level..
There is a button on top for navigating to the parent comment.
Yes, that's how I know they're on the same level. Your two comments lead to the same comment.
Right, but didn't you say that I was answering myself?
Oh Ok. You should write them on one comment though.
Don't care about negative contribution. Improving rating should be main focus.
The sentence about god was the irrelevant in the announcement. If it was not there, no one would have started this.
Would any other kind of irrelevant sentence have provoked such a reaction?
Would you refuse to accept this?
You might have been more comfortable if the entire phrase had been used: "In the name of God, the Most Gracious, the Most Merciful".
lol
Ashishgup held three rounds and now he is a tester in this one. That's a lot of work.
Deleted
I'll definitely be waiting for his first div. 1 round.
I am a beginner.Can any one give some advice about this contest.Please ,It will be helpful for me.
A — dificulty will be less than 1200 & B -will less than 1400 most of the time..practise those problem from problemset with those difficulties . I think it will help
many many thanks for your advice.
If you get stuck on these, read the editorials. They will give you an idea of the sorts of algorithms that you need for problems at this level.
On tuesday at the time of contest open codeforces and start solving some problems
thanks for your advice.
its the best you can get
If it your first contest, don't worry if you don't solve much. Even as a very experienced programmer (40 years as a professional software engineer) it took me a few tries to get the hang of programming contests.
Unless you are in the last couple of minutes of a contest, always try running the provided examples locally (or using "custom test") before you submit. On Codeforces you lose points for failed submissions.
If you know more than one programming language use whichever you find easiest to write. So long as you find a reasonable algorithm, performance is unlikely to be a major issue until at least the 4th of 5th problem. I use Python for my submissions, and (using PyPy3 to run it) I have yet to find a problem that it is too slow for.
Thanks a lot for giving your valuable advice...It's surly motivates me a lot..
Moreover, after the contest is over you can always read the editorials or can refer others solutions. You can practice for any difficulty or any tag from the problemset by using filter provided on the right side.
"Happy Coding :)".
Thanks a lot...... I will remember your suggestions... again thanks a lot .... "Happy Coding you too & this community :)"
As a Tester I feel that the problem set is more diverse and good for everyone , there is something for everyone to solve and ya the round is good for those who just want to start with competitive coding!. Hope everyone to give this nice round!
Nowadays a contest without this declaration is rare.
Ya it is a trend , let it continue!
Hoping to get a big +delta in this round
Are the statements short?
Interesting Question answer is "5961207468652073746174656d656e7473206172652073686f727465722e"
Decode this cipher text to get the original answer.
Ya the statements are shorter.
Well said buddy!
How?
text is in HEX encoding
Any specific reason for the unusual time?
As old time hinders dinner in most Asian countries, xD
So true!
XD
Can't be more correct xD
Totally true!
true...!!
Very Excited for your first contest!!
I think that's the beauty of codeforces. We get the best of problems from different countries which covers lot of diverse types of problems and helps us improve in different areas with each contest. We got 2-3 good indian rounds, this one is an Iranian round and 654 Div2 will be a Japanese round:).
First time when i came across this platform, I found it very weird because it's UI is not very attractive but when i started participating in contests I have just fallen in love with this platform and no other coding platform gives me this much of joy while solving questions. I think codeforces community is really great and helps a lot in growing as a competitive coder.
Now Wish you Bad luck for downvoting bruh!
Stop posting shitty memes!
Downvoted. There's no reason to drag in religion here on Codeforces -- keep it to yourself.
I don't see any reason to not to add a single line, which doesn't hurt anyone in any kind(or does it?). If i could see, then i would not.
I'd say the setter has some freedom to include selected topics in his announcement/problems. A few contests back we defended Codeforces Round #645 (Div. 2) for having the corona-virus theme. Clearly, while the theme is offensive to some people, the vast majority of users seemed to find no harm in the in the author expressing his personal humor here.
We must not adopt double standards: we tend to give our authors leeway to include their personal touch in their contests and announcements. Whether it is references to anime, marvel universes, corona, or religion, a persona touch is usually tolerated by the community historically.
If a subject is considered too divisive then the community will naturally express it with sufficient downvotes, so either way we'll find out what everyone thinks.
I think allowing the authors to add their 'personal touch' is the right approach. It's lots of work to author a contest, they should be able to broadcast their messages to people who read the CF announcements.
Also, I can't imagine too many people caring enough to mass downvote an announcement or editorial. And this is good because most of us are here to improve on our CP abilities and not to get offended by the authors' political views, religion, and memes.
I think as long it is not offensive for anybody, authors can add whatever they want.
You can proudly add it bro. I think, this will not hurt anyone.
I personally love when the authors include their personal touch to problems(or blog) and the editorials. It feels real-like problems. Also if you make an editorial like this I'd love it :-)
Differences are the nature of this world and nobody is right to blame another cause of something that they don't have in common. You are absolutely right!
When You are not start every work with name of GOD means there are not any GOD that is the best.
if he use "In the name of Allah" it may be correct but it's a General sentence and all of people know it and hear it at least once.
Reading it the 5th time. I don't understand what you are saying.
Why you shouldn't use google translate
I agree with GreenGrape, bringing religion into a platform like Codeforces can only divide people.
If it goes on, eventually it will definitely escalate. Maybe, next time someone will say characters in their round are of their religion and its their contest and it should be allowed. Also, not to mention many people do not believe in god or religion, to whom it definitely seems bad.
FYI in Iran it's a formal compulsory custom, much like a head cover for girls. Every article, movie etc. must start with this string. It's not an author's personal statement. More like a national trademark for a text.
please correct me if I was wrong.
Yeah you're right! Just like a white-man in America that MUST be racist if not he should survive under Polices' hits. Just stop trying to make a saint out of yourself.
[Deleted]
No you didn't. And let me make things clear. The author has not followed any compulsories. Just personal beliefs.
omg, why som many downvotes lol? If anyone bothers to explain, I'd gladly read that.
So let me to do so. You just tried to make a bad and ugly face out of Iran with mentioning Iranian "formal compulsory" and pretending that they are just in Iran! And I think you got a proper feedback.
thanks for the explanation
:)
Guys! Just take it easy! You are blaming the author cause of adding a simple line with some common words(And not a verse of Quran!), while you are sharing the black lives matter hashtag on Instagram and Twitter, HYPOCRITICALLY! You put knees on faiths' throat and try to kill them instead of learning that they exist, and you should live along them. I'm sorry if I just hurt someone with a kind of brute comment, but think about it!
Bismillāh is not "some common words", and your metaphor is ridiculous. Regardless, everyone should be free to follow their beliefs and traditions.
Do you see any "Allah" word?! God is a common word that doesn't really refer to any specific religion. It's not Allah, Jesus and things like that which they belong to a religion. Of course God is a common and general word
"Allah" is just an Arabic word for "God", and the phrase is unmistakably recognizable.
Stop being so boring
Are you a militant atheist?
Ok, I'm deleting this meme.
wait what ! 3 memes with 5 Rev. memes game -_-

Here is the truth.
when you go for edit its tell not to change the idea..but you change and change..Nothing else
In the name of God... Me an atheist....
It is going to be an interesting round.
I promise that the problems are not affected by religions in any kind.
I don't know why people are talking so much just for "In the name of God". The main motive should be to participate and learn as much as you can. I think pointing someone just like this is not good. And we as Codeforces Community are "ONE".
I request MikeMirzayanov to make this clear to everyone, please.
Deleted
Are you obsessed with commenting
Deleted
No you are desperately waiting for upvotes
Deleted
Is your obsession for codeforces the reason why you're a top contributor at codechef discuss.
Or is it obsession of commenting?
Great
Please stop downvoting me. I was just asking a question.
Why do you even bother asking these questions?
And then you complain about getting downvotes, asking such stupid questions that can be anwswered by reading the announcement
Looking forward to the contest!
Lol Ashishgup everywhere orz...
[Deleted]
you can not be a good coder by skipping geometry problem.so need to practice more in which you are weak
Why not? One should be ready to deal with anything
I wish there aren't any interactive problems because i'm done with those.
Hey guys..did you notice vovuh is back with his div-3 round...? so excited!!
Yep!
Is it just me or do others feel as well that the quality of comments section is going down? All I see are a lot of shitty memes, "Is it rated" and relentless pursuit from a lot of people to just comment on something for the sake of it. It's extremely uncomfortable as quality discussion on problems gets suppressed due to a lot of this unnecessary crap
You should make a blog about it.
So continuing this series ;)
Stop posting shitty memes
The last time there was a single setter vs an army of testers,Ehab happened! Hope God saves this round!
Please mention about unusual start time in announcement. I noticed it after reading it in comment section.
What is Usual start time?
It is usually 14:35 UTC. I think you should include it in announcement as many presume the usual time.
Thanks dude, I really didn't know it(no joke), blog is updated.
BTW I did my best to make the statements as short and clear as they should be, stories are written in another font so you can skip them, but don't forget to read them when waiting for system test. I tried to lessen number of tests so we should not see long queues.
you lessened the number of tests !
I wish that they are strong so no one solution will fail
Do you think quality of tests is proportional to number of tests?
I didn't say that :)
Congrats on your first round. You are among the most interactive and approachable problem setters in codeforces community. It's your excitement for the round which makes it special.
btw your name is very interestng.
You welcome.
guys post god memes
Stop posting from fake account.
Take Love DeadlyCritic my muslim brother.This is for the first time i have seen "In the name of God(Allah)" in any announcement blog! May Allah help you for your good deeds.
thanks for your explanation!
Polygon is the platform where all the problem is set, tested, and validated for the Codeforces round !!
Simply, Polygon is the manufacturer of Codeforces problems.
All the best to you for your maiden contest!
Thank you for remembering me.
How much money does someone makes by problem setting in these contests ,
Coffee is expensive. :(
How tf are such low quality irrelevant memes getting such upvotes? Not fair to those who work their asses off to make worse memes and still get more upvotes!
The world is unfair ;)
Seeing your ratings graph, I'd say it isn't ;)
how the fuck do you think that is an irrelevant meme . DO you have some sense newbie
Only sufficient for a Wifi or Data Recharge! for next contest!
So you get a recharge for every contest?
Sometimes When my limited netpack (1.5 GB/day ) for the whole day becomes empty then I do take a recharge.
I generally use an opposite strategy, either i don't use net or use it very carefully till the contest XDXD
you guys use personal net?
This is what programmers do, OPTIMIZATION
Why the downvotes ? It's a genuine question...
once again Ashishgup
Why are people downvoting your comment and upvoting https://codeforces.com/blog/entry/78877?#comment-646706 such comments
Because nobody likes redundancy
Edit: Got it. thanks.
Which problem quality? Problems are trash. xD
https://codeforces.com/blog/entry/78877?#comment-646718
.
we don't do that here. :v
Well ,Is there anybody else other than me who can relate to this ?

True af.
Score distributions are out.
I think you want to say Score distributions are out.
Thanks.
dont be critic toward deadlycritic.(ps:just kidding)
Till now I was thinking that the round will be held today. I was prepared for it. :(
OK, got it.
Is this for real? LOL!!
I am waiting for this contest. Hope, it will be very interesting.
Everybody is hoping for interesting problems but not everybody is commenting "HOPE, IT WILL BE INTERESTING" So shut up
who hurt you bro?
Hope your first contest will be more interesting.
I have a good feeling to this contest <3 ;)
me too!
How can i see my solved problem distribution on CF ? (difficulty-wise) Thanks in advance........
Codeforces Visualizer developed by S.J. Sakib
You can use this awesome tool to see difficulty-wise as well as tag-wise distribution of any CF account. Moreover, you can compare yourself with anyone as long as you know their cf handle. AFAIK there is no such option on codeforces.
Thanks.....
You check out Codedrills and simply check by entering your username.
.
To further motivate you, just check ruban 's graph. You will understand the dedication towards cp
I thought my dedication level is pretty strong
But after seeing this I realize, compared to him, mine is nothing!
hats off ruban
UNUSUAL TIME
Stop posting irrelevant memes
please for god sake,stop posting shitty memes.
Atheist: Hoping for an interesting round !!
God : You'll have a difficult time in this contest :p
Me: Yes, I can do it. I can solve all the problems. I will be rank 1. But after solving at max two problems, enough I am done with it. I am going to sleep.
Finally, downvotes
Hope to see problem from number theory
I hope to be a pupil in today's contest anyway.
Countrymate, I'll keep watching over you today!
Wishing you good luck.
Hope you would become pupil in next contest
CodeForces and all the problem setters, coordinators, testers are doing an amazing job to arrange such good contests on such regular basis. Hats Off to their efforts!
ok
Why people nowadays are discussing such irrelevant topics in the comment sections?You guys have other social sites to do these stuffs.CF is not the right place to share memes & have a discussion about if the author can add "In The Name of God" in his post or not.
Why so serious man? Discussion, if not unhealthy, should be welcome everywhere right?
It's only natural that the discussion started in the comment section of the post where the phrase being discussed was used.
I think it's really good to discuss respectfully about such stuff in a special community like coders and programmers of all around the world. Like what we two just did!
Humble request to authors: Don't make it Propaganda forces Thank you!
Expression of personal faith is not propaganda.
Some people are keen on downvoting obvious facts. :)
Come-on man! Just take it easy. Nobody can hold a propaganda by just a simple line with some really common and general words.
Hopefully, your entry as a contest writer will be interesting and hoping for an interesting contest as you said :).
https://codeforces.com/blog/himanshu_attri please someone help me with this problem it will be very helpful thank you in advance this is first time i am asking for help
submissions in queue for a long time. will contest delay?
This time is very unusual as per India. As many of the students stay in the hostel, and it coincides with dinner timings of the mess: 1930-2130 IST. So either we have to skip dinner or lag in the contest.
its not tough to delay dinner about 1/2 hours..Its worldwide..so some people always face problem brother..
dude leave this contest and go to your home first, :)
I don't know if you are lucky to have nice food in mess, I never gave a thought to skipping or lagging in contests for mess food.
U are in college at the time of this lockdown ? Seems very far-fetched :P
Why it is written codeforces and polygon platform, and what is the meaning of polygon platform?
nothing
just google polygon codeforces
GLHF EVERYONE!
i registered but i cant submit my code..
I forgot to register can't I participate now?
What do you expect ? Ofcourse not !
this is so annoying, i have written my code but cant submit it , why should i be penalized for this round if i have already written code and registered..
...
Something called rules
I have registered but cannot submit my code.
I see no reason why that should happen. Have you registered for the contest ?
i was able to submit the code after 10-12 mins after the start of the contest.
Man I keep getting Wa on A again I solved 3 problems and my rating will stay the same :(
At first I thought, at least one edge should be parallel! :(
You need to start working on your reading comprehension. :)
How to solve DWhat was D.can you please prove this.i was able to get both recurrence but was not able to figure out when to put the condition .
The tree of level x can be decomposed into three subtrees of level (x-2), (x-2), (x-1) respectively, which are connected by root node. Claws can be chosen from the bottom. The claw including root is used for x=3. For x=4, one subtree will be of level 3 so its root cannot be used. For x=5, two subtrees will be of level 3 so root cannot be used. For x=6, the roots of all three subtrees are unused so one more claw can be picked. similarly, for every multiple of 3 one extra claw is picked.
I lost too much time convincing myself that the proof for problem B I had in my mind was correct :D Anyway, I really enjoyed the problems. It was a good contest.
"For each test case, print a single integer — the maximum number of yellow vertices Lee can make modulo 10^9+7." — having the maximum modulo instead of the maximum actual answer modulo 10^9+7 was very nasty. Should have been explained better, as usually the problems require the actual maximum modulo something.
What? I think that's just messed up wording, because I solved the standard problem and passed the pretests.
Summary of the contest:
Wrong answer on pretest 2
Easy D
Stop making so big pictures... You can easily resize it.
Sorry, this is the first time I've ever posted a meme. It looked way too big for me as well. Does codeforces has a resize tool built-in?
No, you can save lower resolution in Paint, for example. Now it's nice :)
How to solve D??
$$$f(n) = f(n-3) + 4*T_{n-2,0}$$$
where $$$T_{n,0}$$$ is the number of nodes with degree 0 in the RDB of level n
Please don't write
−In the name of God −
from next time :(Please don't comment
Please don't write −In the name of God − from next time :(
from next time :)Waiting for editorial
How to solve problem E? I tried to model the problem using graph network- food type as node and each friend as edge. How to proceed?
If solution exists then for any subset of people solution exists as well, so try to find a guy who can be in last position.
E should be solved using greedy and has no relationship with graphs.
any hint for problem D !?
Greedy from the bottom
The tree obtained at level I is a combination trees obtained in level I-1 and level I-2. this is. A hint. Now everything is a Dp
Think about how many leaves you can have in a k-level tree. You can build up your solution based on this.
is it solvable by math solution ?
All 1-D DP relations are actually mathematical functions. Same about this one. But obviously, here you would be needing memorization to avoid TLE.
Use greedy and simple dp. The code is quite clean.
How to solve E? It is a variation of Cow and Snacks. How to handle multiplicity of plates?
Nice and hard problem E, thank you author
Alt Account Spotted
I did not like this one. For me D and E where hard to understand, I restarted two or three times just to notice after some times that I did get the question wrong.
Agree. I have to read D and E many times to understand them correctly. The statements are easy to cause confusion.
You tried to make a hard D ? You definitely made a deceptive D. Loved solving it.
Actually earlier D was something Different which you might not Like , this was invented after hardships , this was a really nice DP problem I ever solved.
Video Tutorial B:https://www.youtube.com/watch?v=GhR1nXq6Y7Y
I don't know why my D solution is correct.
Edit: oh nvm disregard
[deleted]
You are very lucky, because the modulo of the max is different from the maximum of modulo. But in this problem the two values doesn't differ from more than 4, so with some luck it works.
you get maximum of two thing that differ at most one. this solotion is correct but our solotin is another thing
Generally
max(a, b) != max(a % mod, b % mod)
Wow, it's true, and my solution with max should fall, but it worked :)
It should not, as we know $$$a$$$ and $$$b$$$ differ by $$$4$$$ at most, so it works as long as $$$max(a \% mod, b \% mod) < mod-4$$$, and smallest such $$$n$$$ was so big.
Did you consider changing Mod value instead of N or was it intended to leave that solution AC?
I didn't realize that I can change Mod, thanks I will note it for my later rounds, thank you. I prefer those solutions to fall, at least one-third of the solutions would fall.
You're welcome :) I liked the problems actually they were very interesting. In the contest I've written solution similar to his one but was sure it will fail and you planed to trick us with such a case so I gave it 10 minutes more to find out the pattern when N is divisible by 3! That's why I tried to generate a valid MOD to prove I was thinking correctly LOL.
:), If the MOD was something special, then yes I would do the same, but not when MOD is $$$10^9+7$$$. Also the sample had $$$2\cdot 10^6$$$, so there were no room for WA. Except some special Time Limit exceeded.
Sure actually $$$1000002193$$$ is the first prime number >= $$$10^9$$$ which could make their solution fail as I tested for each prime all possible values of N. I know it's hard to find such cases unless you predict that someone would do that exact solution while writing the problem constraints!
I think it's OK, this is my code:
Isn't it right? Why you think it's incorrect?
My English is't well, please forgive me. ovo
2*(1e9+7) < maxint
So that it works well
you're comparing 2 numbers that are in module 1e+9 +7, but i dont know why it's AC
To be sure that they will be no errors with the max, you can remark that the second value is greater than the first one if and only if
i%3 == 0
Very descriptive questions. And I must say, the names were quite good too.
Why problem D I can mod then max to pp the testcases?
No need to use max, ans is:
dp[x] = (4*(!(x%3)) + ((2LL*solve(x-2))%mod + solve(x-1))%mod)%mod;
PS: Just clarifying that badcw was asking another thing before, I have no idea why the solution with max works.
Thanks, I check it's all correct in [1,2e6]
Can someone please help me out with B?
you just have to find first and last occurrence of "1" and change substring between first and last "1" to either "0" if any "0" is present in it . or substring remains same if there is no "0" in it
What?!
is something wrong?
(1.......0) : this will always get converted to 0 no matter what is between them.
So,look for the first occurrence of "1" from beginning,lets say that index is x and first occurrence of "0" from last,that index is y.
if(x<y) : Print the string except the part from index x to index y and replace that part with "0". else : Print the string as it is.
This helped, thank you!
Oops! I wanted to upvote, and downvoted instead. Sorry. :(
'A' problem ruined my day,thx