Hello, Codeforces!

<almost-copy-pasted-part>

Hello! Codeforces Round #702 (Div. 3) will start at Feb/16/2021 17:35 (Moscow time). You will be offered 7 problems with expected difficulties to compose an interesting competition for participants with ratings up to 1600. However, all of you who wish to take part and have a rating 1600 or higher, can register for the round unofficially. The round will be hosted by rules of educational rounds (extended ICPC). Thus, during the round, solutions will be judged on preliminary tests, and after the round it will be a 12-hour phase of open hacks. I tried to make strong tests — just like you will be upset if many solutions fail after the contest is over.

You will be given 7 problems and 2 hours to solve them.

Note that **the penalty** for the wrong submission in this round (and the following Div. 3 rounds) is **10 minutes**.

Remember that only the trusted participants of the third division will be included in the official standings table. As it is written by link, this is a compulsory measure for combating unsporting behavior. To qualify as trusted participants of the third division, you must:

- take part in at least two rated rounds (and solve at least one problem in each of them),
- do not have a point of 1900 or higher in the rating.

**Regardless of whether you are a trusted participant of the third division or not, if your rating is less than 1600, then the round will be rated for you.**

The problems for this round were invented by MikeMirzayanov, Supermagzzz, Stepavly and sodafago.

Thanks to MikeMirzayanov for platforms and coordination of our work. Thanks to darkkcyan, Sho, sodafago, budalnik, kocko, akagami_no_shanks, Gassa, infinitepro, bfs.07 for help in round preparation and testing the round.

Good luck!

</almost-copy-pasted-part>

UPD: Editorial is ready!

Every announcement of Div3 round from Supermagzzz, Stepavly and MikeMirzayanov makes me happy!

As aDio

Good luck everyone !!!

Sick, I miss div 3 contests so much, looking forward to participating into this!

Excited

Why you guys stealing memes ???

Run plag check here!

.

I think $$$e^{\pi i} + 1 = 0$$$ is funny to you.

Not as much as

`cin>>name;`

would be for you!is div3 rated for someone with current rating < 1600 but his max rating >= 1900 ??

Edit : sorry i didn't see this

Regardless of whether you are a trusted participant of the third division or not, if your rating is less than 1600, then the round will be rated for you.It's based on current rating only. Max rating doesn't make a difference.

so what about this point

do not have a point of 1900 or higher in the rating.?? what do they mean of trusted participants ?Accounts that have reached a rating >= 1900 at any point can safely be assumed to belong to the stages beyond amateur grade. Therefore, having them part of the "official standings table" that is published is likely to distort the actual standings list.

Similarly, new accounts could be alts to high rated coders as well and including those would lead to similar results.

Therefore, while the round

willbe rated foranyone below 1600(at the time of the contest, I believe — or maybe registration, this is actually my doubt as well). The official standings list published simply won't contain the names of these "participants that may not be trusted as div 3 folk"I'm quite surprised that you had $$$203$$$ contests and you still didn't know.

Is the rated cap for rounds based on the user's rating at the time of the

contestor at the time of theregistration?I tried searching for some relevant blog but couldn't find one.. Thanks in advance :)

At the time of the

contestrather.Calculation of rating, finalization of winners board logic happens after contest as well as validation of being

trusted participantand/orbelow 1600member.Thank you very much for the clarification :)

true story

it is relatable . my mom 's TV sound !! is high everytime i give contest

F

The contest starts at 22:35 in CST(UTC +8). That is the time my family go sleep.

Ah.. Stop farming contribution by someone else's ideas

.

Can't you count to 2?

I just asked that if 2-gon is the international grandmaster 1-gon.. caz many pros make new accounts to give the lower rated contests... but everyone was downvoting it for no reason... N whats up with u man..its not binary. U can be a good coder n polite at the same time!!!! Now dont get overexcited u r just a pupil. Some 150 points more than me!!!!!!

Stop attacking me — I did not downvote you, I promise. :)

Same scene at my home. People having loud fun chat and me struggling to concentrate on how to solve the question

OMG it's true

The most relatable meme that I've ever seen in the comment section this far.

Yah Codeforces Hey!

Yah hum coders hey

Yaha Cowding ho rahi hey!

What do you mean?

It's a play on a viral video from the subcontinent (the South Asian region)

Finally, a div3 round that I missed so much

Codeforces is luv....!

this happens every single time F

What happen if a person whose rating will be more than 1600 after Educational round = )))

1

Previous rating change unrolled, will this contest be rated for me ?

Never mind!

Back to back cf Round :D

Judging by my very poor performance of the last round(spoiler: never enter a round 40 minutes after it started:)) i think that this round should be rated for me. Are the new ratings coming until the start of this div3?

will the new ratings come before div3 or not ??

From the last contest there seems to be less participation because of busy schedules and lot of assignments of college.

Same

As a participant, I wish no "Wrong Answer On Test x" situation.

This is my first time to compete in CF. good luck. 祝我好运！

Okay

Wait is over ❤ Finally div 3 after long time

Thank you ! perfect time for div3

Wtfffff Muffinhead 6 problems in 9 minutes how is this even possible !!

It seems that codeforces recognized him as a cheater because he is not on the scoreboard anymore.But I think that he his Benq with another account any ideas?

Even for a legendary grandmaster that's too fast but that's weird why would he participate in unrated contest from another account

I think it happened once before , remember that video on William lin's channel

I am unable too see problems or register can someone help?

Positive delta YES!!!!

Is it just me or these div3 rounds have become wayy too easy.

Or you have become better?

I don't think so maybe it's just more suitable for the target audience these days.

A Supermagzzz round is an ez round

I think they actually seem easier than the older div3s, especially with the 7-problem format.

I think first few are harder while the last few are easier, nice problems overall.

and here I am couldn't solve even "A"...don't know what's going wrong :(

is this a div4?

I think, it's just real div3

wrong answer using segment tree on g why? Here:107616153

Seriously, how do you expect people to understand your solution just by hinting with some topic.

invented ! =discovered.

Supermagzzz's DIV 3 are easier as compared to vovuh's.

bro more than 2700 people solved F. that's crazy

speedforces :(

I was not particularly quick today but still solved all problems and recorded a screencast with explanations

The difficulty from A-E is in decreasing order

Very true, F was way easier than A and B

Felt more like a Leetcode Contest without its final problem

Can't we solve problem f without using the concept of hashing? initially, I was thinking to declare an array of size 10^9. later realized that it would give any runtime error or memory limit exceed.

Is there any way other than hashing or map to solve f ?

you can store the numbers in an array, sort it and then count how many there is for a given value but it's nlog n

I solved it using Treemaps but Yes You can easily convert it to hashmap solution.

My solution for problem C outputs "NO" in my local device while outputs "YES" when I submit, for input 34. It tried with brackets also, but results are the same. It showing 'wrong answer for test 1'.

my solution is: https://codeforces.com/contest/1490/submission/107615310

Why this solution (for problem F) TLE on test 2. I think the time complexity is O(nlogn): https://codeforces.com/contest/1490/submission/107618301

The time complexity is O(t * MAXN) where MAXN is 2e5, so you got TLE.

Does someone know a test where this solution for G might fail? : https://codeforces.com/contest/1490/submission/107619800

is all problem of div 3 is of equal points or C(poihnts)>B

Equal Points

Spent 35 minutes on this bug. fml.

What the heck is Unexpected verdict

Inside the system there are solutions marked as correct solutions. If one of these solutions fail on a hack (maybe cause of WA, RTE, TLE, MLE, ...) then the hack is marked having "Unexpected verdict".

When it happens, then just wait for a little while. Usually the problem setters fix it pretty quickly.

Problem C why my hacking verdict is 'Unexpected verdict'

Maybe that solution has been hacked before.

Different problem statements, but very similar question to

Ecan you provide link

Finally very good Div.**3** contest! All who are Div.2-level could solve almost all problems.

How to Solve G?

if( prefix_sum[index_j] == xi ) ans = index_j — 1

else if , for some positive integer k if prefix_sum[index_j] + k*prefix_sum[n] = xi or in other words prefix_sum[index_j] is congruent to x mod prefix_sum[n] then , ans = k*(xi-prefix_sum[index_j])/prefix_sum[index_j] + index_j-1; store prefix_sum and prefix_sum % prefix_sum[n] in map to query

Okkk Thanks

Create prefix sum $$$s_1,..,s_n$$$. The condition for which the result is -1 is $$$s_n\leq 0$$$ and $$$x > sm = max_{i=1..n}s_i$$$. Otherwise, if $$$x\leq sm$$$, find smallest index $$$i$$$ that $$$s_i\geq x$$$, the answer is $$$i-1$$$. For the last case where $$$x>sm$$$ and $$$s_n>0$$$. Let $$$p$$$ be the smallest value such that $$$p*s_n+sm \geq x$$$, the answer is $$$p*n + i'-1$$$ where $$$i'$$$ is the smallest value that $$$s_{i'} \geq x -p*s_n$$$. You can find $$$i$$$ by segment tree.

Okkk Thanks.

link to my submission (obviously upsolved) without using Segment Tree. https://codeforces.com/contest/1490/submission/107636300

Can some one tell me where I am wrong in problem B.

Spoilerfor testis in range(int(input())): n = int(input()) l = list(map(int, input().split())) ll = []

I am just removing the extra part (present count — the equal number of c0,c1,c2 that shud be there) from maximuum of c0,c1,c2 and adding it to next one among them ..and then again removing the extra from that part and adding it to next part. But I ma getting WA on runtime error on tc 2. ples help Thanks in advance.

Testcase where your code would fail:

6 3 3 3 2 2 2

Answer is 2, but your code would give 0.

how is the answer 2 ?

How is it two? One two has to be increased twice and one 3 has to be increase once. So shouldn't it be 3?

Sorry my bad, yes it should be 3 not 2.

Easy round, but I found my mistake on G 3 minutes before the end :(

Bruteforces!!

Those who have just started reading Binary Search , they must try to solve problems

C , E , G. All 3 of them decent problems to start with.Why this approach is wrong in B

What if c2==n/3 and c1 is not equal to n/3

Here’s my attempt to screencast this Div3 contest, where I have explained the solutions to the problems later. It’s my first ever screencast, and any suggestions would be helpful.

https://www.youtube.com/watch?v=fbv5NKA9t9c

I hope you like it.

Is this round rated ? as it is showing in unrated contest in my performance graph in profile section

It's rated. I don't know why it shows that for now.

G is a harder version of this problem

I uploaded a screencast: https://youtu.be/InbURHKu_Lk

Is anyone here who solved F using Binary or ternary search?

yeah, using lower bound and upper bound Solution Link

I liked your approach, not sure if it's really binary search. Actually, I was expecting something similar to this:

CodeThis code gives WA at case 3.

To not keep you waiting, the ratings updated preliminarily. In a few hours, I will remove cheaters and update the ratings again!

Why unordered map gets tle in F?

Because of anti-hash test. In these kind of tests unordered_map takes it's worst case complexity of O(n). You can check this blog on unordered_map.

Thanks a lot for sharing this, TIL. I was completely stumped as to why unordered map didn't work!

How to approach problem F if instead of "either zero or C times" we consider "multiple of C times" in the problem statement? (I misread it during the contest).

You can take frequency of frequency of elements as count. Each time just check whether number of elements of that particular frequency * frequency of frequency of elements is max.

I am not sure if you understood what i asked. Or can you please elaborate your approach as to how is this possible without modulo arithmetics by just using frequencies.

F solution. I hope my solution is much clearer. I have just used 2 maps to store frequency of elements and frequency of frequency. The product of this is the number of elements we can have include in our array.

I asked how to solve an alternate version of F viz. "how to solve if we can take all frequencies in a multiple of C times instead of just C times or 0 times", not this! Leave it. Thanks.

My F got accepted in 100 ms but 2000 ms after hacking phase. Collision between values is the reason for this because of hash function?

Yeah sucks, same here.

The one with unordered_map fails but with map.

I purposefully used unordered_map thought it would be faster.

good contest

Rating got changed again ? Something happened?

Hi, Guys! I am stucked on #F on 12 test with time limit. No ideas to fix it. May u help, please?

There is a test makes your unordered map collisions.

Why were solutions rejudged on uphacks?