*I almost copied my previous blog post to separate two discussions: about Div. 4 in general and about Round 640. Please, visit this blog post to discuss Div. 4 rounds.*

Hello Codeforces!

Yes, it is not a mistake I decided to run the first Div. 4 round: Codeforces Round #640 (Div. 4)! It starts on May/09/2020 17:35 (Moscow time).

The format of the event will be identical to Div. 3 rounds:

- 5-8 tasks;
- ICPC rules with a penalty of 10 minutes for an incorrect submission;
- 12-hour phase of open hacks after the end of the round (hacks do not give additional points)
- after the end of the open hacking phase, all solutions will be tested on the updated set of tests and the ratings recalculated
- by default, only "trusted" participants are shown in the results table (but the rating will be recalculated for all with initial ratings less than 1400 or you are unrated participant/newcomer).

I urge participants whose rating is 1400+ not to register new accounts for the purpose of narcissism, but simply to take part unofficially. Please do not spoil the contest to the official participants.

Only *trusted participants of the fourth division* will be included in the official standings table. This is a forced measure for combating with unsporting behavior. To qualify as a *trusted participants of the fourth 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 1600 or higher in the rating.

**Regardless of whether you are a trusted participant of the fourth division or not, if your rating is less than 1400 (or you are a newcomer/unrated), then the round will be rated for you.**

Please, read some of my thoughts about the problems of this round:

- Don't expect A+B level problems :-) It is a real contest with easy but problems. I hope most problems fit in range D3A-D3D problems.
- I'm not sure about order of problems. Try to read all problems or at least most of them. Testers expressed skepticism about the order of the problems but suggested different pairs of problems to swap.

We are just starting, so the complexity of the problems may deviate somewhere from your or my expectations. Wait and see.

The first "thank you" is sent to antontrygubO_o, who helped with the review and selection of problems.

Many thanks to the testers: pashka, 300iq, vovuh, Golovanov399, spookywooky, kocko, Sho10, igor_kz, Sho10, scott_wu, bfs.07.

I hope you enjoy the problems, and the round will be interesting!

Please, leave in comments your thoughts about exactly this round. If you want to write something about the general idea of Div. 4, then visit this blog post.

**UPD**: Editorial is published!

finally ,, thank you :) ; i think this is my chance to become a specialist after 4 years in codeforces

really i solve 2 problem in Dev2 .. so i will try my best here

Best of Luck!!!

.

If you only solved two problems in yesterdays contest, think you need more practice at basic implementation problems :)

Really i had failed... ;'(

Not really clear about how it is going to create an effect on us,hopefully it will motivate us more. And I really hope system won't crash today

is it rated for unrated accounts?

Yes

All I want is a smooth and queue free contest today

How to become tester for CF round? Are testers author's friends or something else?

maybe it's predecided by author or mike!

For testers this problems is easy. Maybe before the round gives this problems to grey people?

I don't think so! Usually high-rated people tend to keep the problems secretly!

Hello!

If i have 1400+ and only 1 rated round and i'll write this div.4 will the rating be recalculated?

Thanks for the new contest :)

I think it won't be rated for you.

Sorry, no. Actually, I have plans to reduce the initial rating (from 1500 to 1200 or even 900). It will remove a series of rating drops in the first contests.

This will be a lot better.

Maybe to 1300 or 1400?

1000 might be better for newbies like me

I just hope that the questions aren't too easy mike!

Please be careful, new rating may become more expensive than the old one (new rating will be harder to get than it was earlier, so it will be impossible to compare old participants with new one).

Also without additional measures you may get the same rating drop but starting from a new initial rating.

Have you considered a few "qualification" rounds instead? Eg. first 2-4 rounds participants has only hidden rating and they get their rating and color only after qualification series finished. This system implemented in some games, eg. Starcraft.

eg. CSGO xD

Mike now that new comers start with 1500.They lose points. Which is gained by experienced users. But if you start their ratings st 900. It will become more difficult for experts and specialists to gain rating changes.

GOOD LUCK TO EVERYBODY!

Affect of Div.4 contests on us:

SpoilerPast: We can only take part in Div.4 contests.

Present: We can only take part in Div.5 contests.

I am looking forward to the problem A. How much difficult it is!

A was not that easy.

Will it be unrated? Like last round?

Because I know you all have so many questions, I have compiled an FAQ:

Q: Is it rated?

A: Yes.

What about last round?

There's also an FAQ:

Q: Is it rated? A: Yes.

However it's still unrated

Recent two Div.1 contests are all unrated T_T

Hope Not to See Atcoder's ABC's A and B problem :)

Today ,we are going to witness a historical moment and be part of it .

Upcoming generation will witness this post and will be enlightened by our high intellectual comments and will praise our intelligence. (First div 4 round on CF)

hahaha

What is the meaning of D3A-D3D problems?

Div3-A to Div3-D

By seeing the upvotes of this blog we can imagine how codeforces comunity got disappoint after div4 got introduced :(

I am new to CodeForces and I am sorry for this question but why does div4 disappoints the community?

Or maybe the majority of people upvoting are pupil and noobies (happy with the free rating increase for them) which constitutes 90% of the codeforces traffic.

There seems to be an unwritten rule to not post an editorial before end of hacking phase. I do not see the point. People discuss problems in the comments anyway after the coding phase.

Is there an official opinion?

No such official rule. I think it is quite OK to post an editorial before the end of an open hacking phase.

Thank you MikeMirzayanov for running an awesome platform not only for advanced users! Maybe it will be helpful for newbies like us.. We will try to give our best shot :)

Is it rated?

Read the post's statements carefully. :-D

(Yup rated but not for all)

My first codeforces contest yay! I plan to become an expert after this round!

make div 3 and div 4 run simultaneously..

Means you want codeforces to make a contest only for specialists??

nearly 25k registrations till now, hope it will not be queueforces.

Thanks for this contest. Hoping to see more div 3 rounds as well(i can barely touch div 2 problems even if i do fails in the test cases)

this(division 4) will be helpfull. great idea..... :)

Sorry mistakenly I clicked on downvote...

i think everyone enjoying this round.

Hope, It'll be the first contest where I proud of me.

All time high.. 26K+ participants ..wow

28.7k is ever highest

Still long queue?

Common, at most 1 minute long on the start. It seems we are starting to forget what a queue is.

Yeah! everything fine now:) Thanks.

is this a really Div.4 are you sure???

And you expected "a + b — c" kind of problem?

Well, usually I hate problems with test cases, but not in this case.

Samples are so strong so I can just submit the solution without carefully checking the answer, since WA 1 doesn't count.

I really appreciate it. Thanks, Mike.

I would recommend checking for the sample tests before submitting though. It's the least we should do to put less load on the server.

Since Mike wanted to test the system under load, I think, it's even better to submit a solution whenever you think you're ready. (and, probably, resubmit after WA1)

meanwhile specialists today: " i am superman!!!"

Nice contest!! (Although there can be a slight increase in difficulty of F or G as also in Div3 end questions are around 1700-1800 rating.)

End questions in div 3 are not 1700-1800. More like 2000-2400.

End is relative :)

The queue time almost does not exist! Thanks for the great round!

well there are 40+ pages on queue so...

40 pages = 2-4 min of queue

40+ pages of pretest. The setters are trying their best to put a lot of good test cases in a small amount of cases. I dont think it would be an issue.

What div.1 and div.4 have in common for me: having nothing to do for about half an hour before the end.

ayaya that made me laugh but its mutual

Thx! That's why I chose Codeforces. It's a good website to learn English and get contribution as well.

Very good work of the codeforces administrators, the queue time was significantly reduced. The queue time for round 639 was around 40 minutes while in this round the cap was 2 minutes. I think codeforces is ready for div 1 and div 2. Thank you for your wonderful work.

I solved all problems in this first contest of Div 4!!!

I'm so happy about it!!!

Officially, I have the 12 place in official list of participants!

Predictor says that I will have +330 rate!!!

Amazingg~!!!!!

Love you, Mike Mirzayanov!!!!!

P.S. Mike made my dreams come true!!! I really want T-shirt with your autograph, cause you are my superstar!!!

Congratulations. Keep this motivation, and you will be successful.

Well done! Now make sure you won't get hacked :(

I doubt if you've done it yourself. I'll personally check all your submissions on my MOSS and report any plagiarism case to codeforces. Simply not possible for a grey (unless alt ofc)

Bro chill. No need to report him to CIA.

If I remember correctly, you are that guy who defended Karan Gujjar. Now u r accusing everyone of cheating. This contest was no big deal anyone could have solved all the problems. Instead of motivating him, you are accusing. Grow yourself

Now thats what free rating for others look like. Believe me you have gained free ratings for others. Now div 4 will make upper div2 player easier to gain ratings

I think the order was a little unbalanced. It should be

A C B D E G F

OR

A C B D G E F

OR A C B D G F E

I dont think so F was the most difficult problem acc to me

A C B D E G F seems to be the order of difficulty according to the AC counts.

Really? I thought E was simple and didn't require any experience dealing with similar problems, even though you had to work around the memory limit some. Meanwhile I had no clue how to approach G since it wasn't something I was familiar with.

Solution of E Odd numbers in decreasing order then 4 then even numbers in decreasing order. For n = 8 7 5 3 1 4 2 6 8

Damn, knew it was some trivial pattern I was missing. Thanks!

I also didn't find a pattern at first, so I did a dfs search to find the solution.

Can you explain further how can dfs be used to find pattern ?

You consider all the numbers as nodes. The edges are between the pair of numbers that are 2-4 away from each other. The you start dfs searches from all the n numbers and try to somehow get all of them in one search. You can check my code for details. The complexity is O(n^2) however.

Isin't this the solution of G.

He asked G :)

A B C E D F G

In my opinion it's A C B D F E G

If you are a Newbie,I think ACBDGEF is better

(But it is ACM-ICPC so it doesn't matter)

Finally I reached purpilll!!! Plz keep holding div4!!!

Problem of long queue has improved a lot wrt last div1/2 contest!

nice problems, especially E. looking forward for more such contests and problems.

sire, please explain E to me. Couldn't understand editorial properly enough.

When you solve 4 problems in div3, but here you solve one......

I like problem A. It is easy but interesting and has an educational value.

Unofficial editorial in Python 3. For more editorials see my discord http://interview.solutions

## Problem A

Problem A - TutorialEach number like 1234 should be written as 1000 + 200 + 30 + 4. We ignore any zero digits, so 10203 = 10000 + 200 + 3.

Problem A - Solution## Problem B

Problem B - TutorialIf the task is possible, we should write either: [1, 1, ..., 1, x] or [2, 2, ..., 2, x].

This is because the requirement for the last number is that it has the same parity, and it is positive. The requirement of being positive is the same as the sum of the other numbers being as small as possible. Therefore, we make the requirement strictly easier by decreasing the other numbers by 2 (if possible.)

Problem B - Solution## Problem C

Problem C - TutorialThere are three possible solutions.

Solution 1 (lifting): Say k >= n. We could remove the first n numbers from contention: k -= n — 1, and now we start counting from n + 1 instead of from n. For example, if n = 10 and k = 15, we know that in the first 10 numbers, there are 9 not divisible by 10, so we start counting from 11 with k = 15 — 9 = 6. If we did this naively, we would get TLE because k could be really big and n really small.

We could scale all the numbers involved to do this faster. For example, let's scale by 1024: if k > n * 1024, we know that in the first n * 1024 numbers, there are (n-1) * 1024 not divisible by 10, so we start counting from 1024 * n + 1 with k -= (n — 1) * 1024.

Solution 2 (binary search): Let f(x) be the number of positive integers <= x that are not divisible by n. This is a monotone increasing function and we want the first x such that f(x) == k. We can binary search for the answer.

Solution 3 (math): Write k = (n — 1) * q + r [with 0 <= q, 0 <= r < n — 1]. The first q groups of n numbers has (n-1) * q not divisible by n. If r > 0, then the k-th number is just q * n + r. If r == 0, then the k-th number is just q * n — 1.

Problem C - Solution## Problem D

Problem D - TutorialWe just simulate each turn of the game carefully. Here, the pointers i and j will represent the next candy that Alice or Bob respectively will eat if given the chance to.

Problem D - Solution## Problem E

Problem E - TutorialWe should find all special numbers — numbers that can be written as a sum of two or more consecutive terms in the array. After, for each element of the array, we check if it is a special number.

Problem E - Solution## Problem F

Problem F - TutorialNotice we can replace 0 by 00 to satisfy the n0 requirement, and replace 1 by 11 to satisfy the n2 requirement.

So let's satisfy the n1 requirement: let's write 010101... first. Then replace the first 0 and first 1 with repeated zeros and ones.

For example, say n1 = 3. We write 0101 first. Now n0 = 4 and n2 = 5. We modify this to 00000 111111 0 1 (spaces added for clarity.)

Also, if there is no n1 requirement, then the string must be all zeros or all ones.

Problem F - Solution## Problem G

Problem G - TutorialSolution 1 (even/odd walk):

Since we shouldn't walk to adjacent numbers, let's walk along all even and all odd numbers. In general, our walk is going to start with [2, 4, 6, 8, ...] and end with [..., 7, 5, 3, 1], and we just need to handle what happens in between. We can deal with this based on cases where n is even or odd.

Solution 2 (reduce by 5):

Look at the sequence [ 1 4 2 5 3 ][ 6 9 7 10 8 ][ 11 ... ] ( brackets added for clarity ). It repeats every 5 terms. If N is very big, we could write a group of 5 terms in this way first, reducing the problem to a problem about N — 5. Afterwards, it remains to just handle N <= 8 individually.

Problem G - Solutionthank you

In E you could also check if any window on this array sums up to

`a[i]`

. Sliding window works for`O(n)`

, so the total time complexity would be`O(n*n)`

and no additional memory needed, except for the array itself.P.S. Okay, I didn't see that you use only

`O(n)`

memory, so nevermind, your solution is better.Thank you so much，mogul!

For G you can reduce by 4 and then handle 3 cases

I think simplest solution is starting with length==4 and then add odd numbers to the left, and even to the right until the wanted size is reached.

Thank you!

Really concise and to-the-point editorial.

Thank you very much

I loved Problem G! It reminded me of one of my favorite problems on Codeforces: 24 Game

Hi everyone! I uploaded screencast of this contest by this link (Solved all problems in 48 minutes!).

Hey which approach in problem E would cause MLE?

I used a set to store all possible sums, which caused MLE.

Ohh then I think space complexxity with O(n^2) will cause MLE

My workaround was to only store possible sums $$$\leq max$$$ and that passed.

This solution got MLE, submitted to PyPy 3

I switched to C++ so I could use a

`bitset<8000*8000>`

instead.for all i <= n we have a_i <= n so you don't need to save sums > n.

You're right! That totally slipped my mind. I forgot that you only needed to check numbers within the array itself if they're special anyway. Good catch.

problem set was great. and I think your experiment has become successful. Today There is no Inqueue problem.

Since I was tester in this round I was not able to participate. But I used the time to write an unofficial editorial

The problems were easy but very interesting!

I think there are some problems with that. According to the prediction results of CF preidcitor, the div4 rank1 will increase 341 score after this round. So, his new rank will be 1733 (1392+341). I think it unbelievable. Maybe his new rank is too high.

Yes. this is unbelievable. By participating div2 or div3 one can be hardly rated like this. so I think Mike should change his strategy.

Yes, I think so.

If we could solve all questions in 47 mins, he definitely deserves expert

I'm just taking rank1 as an example. I mean maybe the strategy should be changed a little.

It seems that we can't view other's source after the contest?

UPD: it's ok now

I'm not sure if it's only me, but while submitting a solution I kept receiving a message saying "Unexpected error". This happened for about 5 minutes and then everything was normal again. What could be the reason?

Thank you for hosting div4 and I encourage you to do so again in the future.

I think it could've been div3 if one more difficult problem was added, and 1-2 current problems removed?

I don't think so Problems were relatively easier than Div3 No Graph dp or greedy.. Div3 contains at least 2 problems including such topics and hard brainstorming :)

According to me problems feel significantly easier than Div3, even F and G feel approximately the same level as an average Div3 D / Div2 C. Usually Div3 F is also fairly tricky and comparable to Div 2 D level problems.

Yeah, but that's where you're wrong buddy. See statistics show that average 1300-1500 rated people solve generally up to 3 questions in Div 2 and up to 4 (maximum) in Div 3. They don't go for E, F, G usually in Div 2/3 contests. The level of problems was similar to that of Div 3 for the first 3-4 problems and many people like me don't care for the last few problems(F, G) so doesn't make a difference if it's easy to difficult than usual div 3.

G was Div2 B at most. Answer was trivial

how is it possible to have runtime error on c++ 11, but not on c++ 17, when someone uses only vector?

happened with me once when i had not included header file

I was about 30 seconds short or else I would have officially done that last problem...

Anyways I enjoyed this round and it really for first time in life taught me that i should have good typing speed

I encourage to have more div.4 rounds

It motivated me a lot

Not satisfied with the order of problems!!!

With me, the G problem is easier than the F and E, but I couldn't solve it in time:((

Exactly!

The first time I solved all of the problems. What an amazing first experence to me. I'm so happy to attend this round even though I'm out of competiton.

Thanks

MikeMirzayanovfor providing such contests. Finally I have solved a problem in an online contest. Thank you for providing such contest . Also, introducing Div4. contest was an awesome initiative. Keep continuing such kind of contests.Why am I in practice mode, and how do I hack?

Select somebody's submission and click hack!

Good time , why my code for problem A with g++11 compiler got wrong but with g++17 got Accepted? from the begining I try to change my code and fix it , after the contest I got problem is the compiler I choose for code :(((

please help me, I'm confused :(

In my pc with compiler g++11 code worked but in website not Accepted and only with g++17 Accepted!!

It will be easy for people to help if you add link to your submission.

OK

https://codeforces.com/contest/1352/submission/79569105 this is a sample of wrong answer with g++11

https://codeforces.com/contest/1352/submission/79568929 this is a sample of Accepted with g++17

both code are same

Make your own pow() function. Hope it will work.

Thanks this approach worked. so problem is g++11 pow() precision?

As pow has return type double and you are typecasting it to integer then there might be precision loss.

Simple solution for problem G: if n<4 clearly no answer exists else first keep 3,1,4,2 in a deque and alternate appending elements between left and right. My submission link

I too used the same approach :)

I wrote a naive brute-force recursive function which seems to work fine. check this

I did not like this but simple like you. My submission

Simple solution for G again!

Put odd elements first in decreasing order then from even elements first put 4 then 2 then same order from 6 till last even element in increasing order.

Although it's div4, I still think it's very difficult. Maybe I'm too bad.

Same bro, feel you!

i felt so bad i tried some got TLE .... i usually solve 1 ques from div one

Did anyone else feel that the level of Div 4 was somewhat similar to Div 3? I mean, there is a noticeable difference between Div 2 and Div 3 but I don't think i can say the same about Div 3 and Div 4. (In the previous three Div 3 contests, I could comfortably solve 2 questions well within 30 mins but could only solve A and C today). Anyways, the problems were good, hope to see more such contests.

Yes even I feel the same, Last time I was able to solve 3 div3 questions but today I got struct at problem 2nd

That was because ABC of div4 had identical difficulty to ABC of div3. The difference was DEFG of div4 were same as D of div3

Why does not O(n^2) solution for E TLE? I thought they reduced constraints to keep those away, and tried to do that in LogN time. Still, 8000^2/2 is a lot of time for one second, and solution passes in 70 ms. What about cases with all 1's?

$$$O(n^2)$$$ for $$$n=8000$$$ is $$$64000000$$$ which is less than $$$10^8$$$ operations. Codeforces can comfortably handle $$$10^9$$$ basic operations in one second, so a $$$O(n^2)$$$ algorithm is safe to use.

10^9 operations take 2 seconds or more.

I should've clarified: You can run $$$10^9$$$ basic operations in under a second (see this as a naive benchmark that runs in 826ms) even though $$$10^9$$$ is likely unsafe for most $$$O(n)$$$ algorithms that are doing more than a single operation each iteration.

n*n*logn is giving tle. I checked using map. So 10^9 not possible in 1s i think.

use

`unordered_set`

instead of`map`

which will give constant O(1) time on average for element access and insertion and also would use less memory than`unordered_map`

I solved it using integer array instead of map. I was just checking whether n*n*logn passes or not.

Heyy i just saw a something unusual

When i generated a testcase of 8000 1's and fed to my program it tool

`~3.5 seconds`

and on codeforces same solution and same testcase have time of`155ms`

for solution EUPD: Now i just ran my program with -O2 command for optimization. Sorry for such noobie question

The 3.5 seconds benchmark is from your computer?

Yehh i just don't know what happended

But when i used -O2 in compilation command it reduced to

`~0.29 seconds`

I am not able to find what cause such an optimization to my byte code

Then it's not comparable. You can use codeforces custom test to make valid comparison

Thanks buddy

correct! map is a self balancing BST! so operations like searching are O(log n) and for inserting its O(log n + balancing time). unordered_map is a hash table so average search time is O(1) , worst time could be O(N) if collision occurs in hashing data.

PS: if anyone could explain me about balancing time of BST.

To explain balancing of BST a few tree is necessary to draw. The BST are generated in such a way that it has equal left and right child. So that searching complexity is always log(n). For this purpose tree may need to be rotated after insertion of value.

You better search google for more explanation using graph. Red black tree is one of the self balancing BST.

thanks! I have recently started with trees and graphs.I ll try to search it and learn more!

No,In problem E n*n*logn using map solution works fine.

I tried to hack my last submission,but failed.

yeah Correct, but it depends on heaviness of operation too, like modulus and division are costly for processor.So for safe limit I take 10^8.

I had mixed feelings for div4, but after the contest i think this is a really cool idea, being a beginner i think i learnt a lot and i think this will help other beginners too..hope to see more div4 as well as div3 contests

I solved just one problem. It was still fun because I could finally read the problem statements and know what was expected of me. I hope to get better in the upcoming rounds

I have been satisfied with the contestA very cool round. Keep the good work going, Codeforces administration team.

Nice problem set

What I thought about Div4 is its difficulty level is still more for a person like me under 1200 as. let say problem 2nd, it was much more difficult as compared to Div3.

Screencast of this round. Click here , I was able to solve upto F.

Congratulations. I would have probably solved problem F had the contest duration been 2:15 hours instead of 2:00 hours.

I doubt,that one test included n=0

I'm talking about last problem

Why do you think so? Constraints says n>=2

Because I tested it for all 2<=n<=1000,there was no problem. then I tested it on test n=0 which gave me runtime error. Verdict was also runtime error.

You are using a for loop until i<=ans.size(). It should be i<ans.size()

thanks.

Nice problems! My screencast of the round

in Chinesebilibili BV1tT4y137wS, don't forget to 一键三连!Interestingly, the Div4 seems to be harder than the first few Div3 rounds (although Div3s are relatively harder now). Do you have the same feeling?

i request you to screencast in english that will help lots of people who don't know chinese.

You see, there are some other English screencasts, you can watch them. My English is not good enough to record a screencast fluently. And for the same reason as yours, I also want to help those Chinese that are not so good at English. Sorry~

Could someone try and hack my D? PS : I think the worst case is with 200 test cases each having 1000 elements. Also I didn't use 2 pointers, and it is most possibly O(n^2) per test case.

Can you show a link to your solution, thanks

Link

It's seem like you used 2 pointers.

N2 is due to building the remaining vector again after removing some elements I believe, eg. For case when we always take 1 element every single turn

I tried hacking it with 200 testcases and each testcase with 1000 elements such that each time only one element will be chosen by either of them. It worked fine or I wrote the generator wrong.

Your solution in worst case loops (n*(n+1))/2 times. that is (1000*500) = 5e5 for each testcase which means 1e8 for 200 testcases and I guess 2 sec is enough for that.

Yep, seems right!

Looks like,worst case for your solution is T=200,where every case is - "1000 1 3 5 7 ..... 6 4 2". This is working in 421ms.

Yep me too and i think test 3 of cf is the same too.

It was a great contest the queue was very well handled and a lot of participants too... Indeed I had a lot of fun in the contest... Helped me in solving the problems as fast as possible...

This round was super frustrating for me! I've been putting a ton of hrs to get better at CP (DP, Graphs, Fenwick tree, strings..). But then I face problems like B or C where I don't really know how to tackle those, and there are Math formulas that I'm simply missing. :( Any suggestions on how to improve for those kind of problems. Thank you.

Do not try hard stuff. Just try to solve A and B more and more (to decrease the time) then gradually move to C, then only you have to learn some algorithms and data structures that you can easily find in tutorials also.

I have never learned Fenwick tree. I think what you claim to know is more or less everything needed to get to Div1. Just try to solve problems from the actual rounds.

wow spookywooky becomes tester(cyan as well XDXD #worst year \ (•◡•) /)

Can somebody explain why this solution to problem E is getting TLED ?? 79579514 it runs I think within 1 sec locally.

Use vector instead of maps, and do not

`mp = mp1;`

instead do`mp.swap(mp1)`

Hey guys, I'm curious about the solution of Question E.

You can actually exhaust all intervals in the array and compute all possible special numbers and got AC. How could O(N^2) solution with N<=8000 pass 1000ms?

The O(n^2) solution is accepted. Because the server can do 10 million operations in a second

Isn't the square root of 10 million around 3150? I actually gave up the O(N^2) solution and didn't submit anything for E because I thought it would have TLE, turn out it's acceptable...

Just try it. There are only +/- operations so that the server can do more operations in a second.

Because for n=8000, n*n=6.4*10^7 and 10^8 iteration can easily pass on 1000ms

damn...I didn't know 8000^2 can pass 1000ms easily... what a shame that I didn't try O(N^2) anyway... thank you guys

N^2 turns out to 64000000 < 10^8 which roughly takes 1000ms

div 4 was a great round

Here is a video solution to this contest: https://www.youtube.com/watch?v=w11pV4hPCxE

MikeMirzayanov, I want you to take action against them. Look at their submission for problem G. https://codeforces.com/contest/1352/submission/79508238 and https://codeforces.com/contest/1352/submission/79550067. Two submissions are almost identical. They also got hacked in problem A with almost identical code. They might share code as they are classmate!

snitch

Their rating table is almost identical.

For C, I saw a very simple solution: (k-1)/(n-1) + k. Can you please explain why this works? Thank you :)

let z be ans: z — floor(z/n) = k. => z = (k*(n) -1)/(n-1), -1 is due to floor function.

On reduction, your formula becomes: (k-1 + kn — k)/n-1 that is z = (k*n-1)/(n-1)

When the rank will be given?

Не могу сдать решение задачи F Восстановление 01-строки на Паскале (на пример посылка №79588069) . При проверке и запуске на сайте программа останавливается при вводе тройки данных "2 0 0". Переставлял эту тройку данных внутри теста — далее её не идёт вывод ответа. На своём компьютере получаю верный ответ 000.

здоровья Вам и Вашему дельфину!

It is really really helpful.. please increase the frequency of such contests bcz it boosts the confidence of new comers .

Finally a good contest... It will definitely boost our(newbie) confidence.

Hey, codeforces if you are listening we need more contest like this...

Have we got a conclusion that the server works ok and there will not be a long queue problem?

It was a great round.Such rounds should be hosted more frequently if possible. A lot of the new coders will certainly be eagerly waiting for the upcoming rounds.

Reading through Mike's post and comments here I really appreciate all the efforts he is putting into trying to make codeforces more inclusive. Added to that how quickly codeforces acted on the changing of its growing community.

@MikeMirzayanov Hi Mike. Please see this when you have time. https://codeforces.com/blog/entry/59228#comment-428171

I knew it will happen like this. And I'm sure div 5 is comming.

Is this round rated? I didn't find it in the announcement above.

yes it is rated.

Div.4 should happen more frequently. It will help a lot of beginners like me.

I just want to say this.. Please include better sample cases for upto B problems if possible. (The sample test cases missed out on couple of crucial edge cases and had me running for it for an hour)

The problem D has good sample cases and I do not see why it would hurt to include a couple of testcases for the easier problems (logic wise)

Its hard to debug an easier problem with too many edge cases as intuitively it feels too correct.

(Just leaving my thoughts as implied in the blog)

is this contest not rated? Because it is written Contest finished but rating is not updated

Updated now.

Please be patient. System has to catch cheaters after the contest, which requires time.

I took part in the contest last night and I was unrated before the contest.Why am I still unrated now?

Because the rating is yet to be distributed. Maybe in couple of hours it will be done. Until then you will be unrated.

I used ideone for my submissions. As I am new to competitive programing, I was unaware of the fact that ideone makes our code public.Apparenty someone stole my codes and used for submissions. Now I am receiving a message from codeforces that my account may be blocked. Please help.

Do not use ideone again.You must keep your code private.

It's better to use vs code or codeblocks.

Codeblocks is my choice here although the best one I like is Sublime text 3

Always prefer offline softwares for these competition because chances of plagarism increases, I personally suggest you Sublime text 3

I think this contest was more difficult than the previous Div.2 contest(My mind)

Actually sorry to say that ST_OJ is my another account. And Sauda_1804063 is also my account. That’s why this two account’s submission was same. I am really very sorry to say for this coincidence. But why I didn’t find any rating for this accepted code that was submitted during contest ?

One question. Am I a trusted participant?(I have participated)

Maybe I find a bug in the rating calculating..?

yet_another_ATS was -18 before this round.

But in the contest rating change page,he is 100 → 994,+894.

And in his homepage,he is -18 → 994,+1012.

What's wrong? MikeMirzayanov

Damn 1012. Oof thats too much.

It seems that for participants with rating lower than 100, during rating calculation they are considered 100.

I hope we have more contests like div4 next time also, it gives confidence and increases the speed also as you know the question is easy and you are in the pressure of completion of the question as swiftly as possible. Liked it as in case of giving div2 or 3 when we are not getting a solution or we have submitted it wrongly most of the times a coder leaves the contest thereafter in the midway but these kind of contest not only energises you but also motivates you to do more and more

MikeMirzayanov Only trusted participants of the fourth division will be included in the official standings table. This is a forced measure for combating with unsporting behavior. To qualify as a trusted participants of the fourth division, you must:

take part in at least two rated rounds(and solve at least one problem in each of them),still many new account gain +300 rating is this is bug or contest is rated for new account.

This contest is rated for new account.

then u don't think this is unfair for many expert and specialist... in this contest new account gain 100-300 rating.

future : div4 ==> fake(new) account contest

well,there may be some new pupils and newbies,so i think it's necessary for div.4 rounds to be rated for new accounts.

anyway no one can stop the high-rated ones using new accounts xd

well i think differently this contest is rating for div4 (<1400) it should be unrated for new account or new account rating should be dropped from 1500 to somewhere 1000-1300

oh,this may be a good idea.

after calculating the rating change,for unrated ones,their rating can't go up but only go down.if they go up,just ignore the change and let the account be 1500,specialist

They will be not in official standing but rating will be changed for everyone who has rating less 1400 and who is unrated no matter he is trusted or not.

5000+fake accounts this time:(

The highest rating change user is definitely a new account made by another user. Isn't this a problem ?

The round was rated only for people having rating 1400 below ,,,, The max rating gain is +365 ,,, Which means the person's rating went above across 2 divisions!!! Is that a fair thing ? Im not sure though ,,, maybe it is ,, maybe it isnt !

Hey, pls check the rating changes, there is a bug. The participants whose rating was 1500 got an increase in the ratings.

Round was rated for unrated users. But some of them are new accounts made by pro coders :(

For those participants, this contest was their first codeforces contest. The initial rating of a new participant (unrated user) is 1500. That's why their rating has been changed.

Users who have created new account, and have got top ranks in this contest, have got a huge increment in their ratings. Their final rating is more than 1800. This is because their initial rating is already 1500. This is not fair, I guess. To handle this situation, the new participants in Div. 4 contests may have less initial rating (around 1400), rather than 1500.

So far the only people I have seen complaining about this are cyans and low experts. Coincidence? I think not.

First of all, I would like to add that even I could have created a new account and according to my ranking, I could have easily got a rating much higher than what I currently have. But it's unethical.

Instead, It is just the true and fair spirit that we are trying to promote. Hope it clears the whole point.

Guys, I think the div4 contests are getting too much hate. How else will the Forever Pupil Gang become expert, if not through solving a bunch of easier problems?

Haters will say they can just practice harder problems and get good.

I feel special nowHi Mike! I have a question for you: will you do another div4 contest or this was the only one? Thanks! Luci

What if div3 & div4 will be together like div1 & div2. E.g. (div4) B or C = (div3) A or B. And those who more than 1400 will write div3 or there will be a new Div?

A good contest... E question good not in terms of concept but in terms of Limits telling the coders, space is also something that matters, which most of the people forget!!! Another way of saying no to O(n^2)!!

It was my first contest, and I really liked it. Got 2 accepted, but made minor mistakes in C & D. :(

Why for mine the round is unrated? I don't use any multiple accounts but I got a meessage that I violated the contest rules by using multiple account. But i didn't. Why it causes? I was expecting a big positive change after yesterday's contest in my rating. But anyway, it didn't.

Can anyone told me why it happens??

It got this message also some days ago..... And then, I use many of variables which don't use other users like testcase variable to TEST_CASE, list to LIST... etc.

But I got the message again.

Respectively Mikemirzayanov sir, Can you fix this issue, please?

Thanks mike! ,for this Div.4 round...I had lost my confidence somewhere but now after giving this round it has come back...I want to see more numbers of Div.3 or Div.4 rounds so that we can move one step forward in this journey of competitive pragramming. once again thanks mike and all other helpers to prepare this rounds....it was great idea.

Could someone explain in the example for problem E why the answer is 4 if n=8 and a=[8,7,6,5,4,3,2,1]? Isn't the answer supposed to be zero?

It isn't because

Now I see, I misunderstood the statement, I thought it is

`1≤l<r≤i`

, but in fact it is`1≤l<r≤n`

.What does

D3A-D3Dmean?This refers to a typical difficulty of problems in Div3 contest given as problems A to D. ie not very difficult problems.

For problem F n0=2,n1=0,n2=2 This test case is possible??

Hey MikeMirzayanov are you still encouraging hacking of solution by the same participant? I see here a violation of hacking. Has any action been taken? The account is still active.

will there be any more div 4 rounds?

no div4 anymeore11!!!! because it is fial! i predict good