### MikeMirzayanov's blog

By MikeMirzayanov, history, 3 weeks ago, ,

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:

• 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.

• 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!

• +333

 » 3 weeks ago, # |   -9 finally ,, thank you :) ; i think this is my chance to become a specialist after 4 years in codeforcesreally i solve 2 problem in Dev2 .. so i will try my best here
•  » » 3 weeks ago, # ^ |   -10 Best of Luck!!!
•  » » 3 weeks ago, # ^ |   0 fir se kata
•  » » 3 weeks ago, # ^ |   0 If you only solved two problems in yesterdays contest, think you need more practice at basic implementation problems :)
•  » » » 3 weeks ago, # ^ |   0 Really i had failed... ;'(
 » 3 weeks ago, # | ← Rev. 2 →   -15 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
 » 3 weeks ago, # |   -24 is it rated for unrated accounts?
•  » » 3 weeks ago, # ^ |   +38 Yes
 » 3 weeks ago, # |   +1 All I want is a smooth and queue free contest today
 » 3 weeks ago, # |   +1 How to become tester for CF round? Are testers author's friends or something else?
•  » » 3 weeks ago, # ^ |   0 maybe it's predecided by author or mike!
 » 3 weeks ago, # | ← Rev. 2 →   +11 For testers this problems is easy. Maybe before the round gives this problems to grey people?
•  » » 3 weeks ago, # ^ |   +4 I don't think so! Usually high-rated people tend to keep the problems secretly!
 » 3 weeks ago, # |   0 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 :)
•  » » 3 weeks ago, # ^ |   +18 I think it won't be rated for you.
•  » » 3 weeks ago, # ^ |   +147 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.
•  » » » 3 weeks ago, # ^ |   +7 This will be a lot better.
•  » » » 3 weeks ago, # ^ |   0 Maybe to 1300 or 1400?
•  » » » 3 weeks ago, # ^ |   -16 1000 might be better for newbies like me
•  » » » 3 weeks ago, # ^ |   -12 I just hope that the questions aren't too easy mike!
•  » » » 3 weeks ago, # ^ |   +24 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.
•  » » » » 3 weeks ago, # ^ |   +1 eg. CSGO xD
•  » » » 3 weeks ago, # ^ |   +7 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.
 » 3 weeks ago, # |   0 GOOD LUCK TO EVERYBODY!
 » 3 weeks ago, # | ← Rev. 3 →   -20 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.
 » 3 weeks ago, # |   0 I am looking forward to the problem A. How much difficult it is!
•  » » 3 weeks ago, # ^ |   0 A was not that easy.
 » 3 weeks ago, # |   -31 Will it be unrated? Like last round?
•  » » 3 weeks ago, # ^ | ← Rev. 3 →   +3 Because I know you all have so many questions, I have compiled an FAQ:Q: Is it rated? A: Yes.
•  » » » 3 weeks ago, # ^ |   -20 What about last round?There's also an FAQ:Q: Is it rated? A: Yes.However it's still unrated
•  » » » 3 weeks ago, # ^ |   -10 Recent two Div.1 contests are all unrated T_T
 » 3 weeks ago, # | ← Rev. 2 →   +1 Hope Not to See Atcoder's ABC's A and B problem :)
 » 3 weeks ago, # |   +10 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)
•  » » 3 weeks ago, # ^ |   0 hahaha
 » 3 weeks ago, # |   0 What is the meaning of D3A-D3D problems?
•  » » 3 weeks ago, # ^ | ← Rev. 2 →   0 Div3-A to Div3-D
 » 3 weeks ago, # |   +1 By seeing the upvotes of this blog we can imagine how codeforces comunity got disappoint after div4 got introduced :(
•  » » 3 weeks ago, # ^ |   +2 I am new to CodeForces and I am sorry for this question but why does div4 disappoints the community?
•  » » 3 weeks ago, # ^ |   +1 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.
 » 3 weeks ago, # |   +5 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?
•  » » 3 weeks ago, # ^ |   +52 No such official rule. I think it is quite OK to post an editorial before the end of an open hacking phase.
 » 3 weeks ago, # |   +1 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 :)
 » 3 weeks ago, # |   0 Is it rated?
•  » » 3 weeks ago, # ^ | ← Rev. 2 →   0 Read the post's statements carefully. :-D(Yup rated but not for all)
 » 3 weeks ago, # |   0 My first codeforces contest yay! I plan to become an expert after this round!
 » 3 weeks ago, # |   0 make div 3 and div 4 run simultaneously..
•  » » 10 days ago, # ^ |   0 Means you want codeforces to make a contest only for specialists??
 » 3 weeks ago, # |   0 nearly 25k registrations till now, hope it will not be queueforces.
 » 3 weeks ago, # |   0 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)
 » 3 weeks ago, # |   +1 this(division 4) will be helpfull. great idea..... :)
 » 3 weeks ago, # |   0 Sorry mistakenly I clicked on downvote...
 » 3 weeks ago, # |   0 i think everyone enjoying this round.
 » 3 weeks ago, # |   0 Hope, It'll be the first contest where I proud of me.
 » 3 weeks ago, # |   0 All time high.. 26K+ participants ..wow
•  » » 3 weeks ago, # ^ |   0 28.7k is ever highest
 » 3 weeks ago, # |   0 Still long queue?
•  » » 3 weeks ago, # ^ |   +91 Common, at most 1 minute long on the start. It seems we are starting to forget what a queue is.
•  » » » 3 weeks ago, # ^ |   +4 Yeah! everything fine now:) Thanks.
 » 3 weeks ago, # |   -26 is this a really Div.4 are you sure???
•  » » 3 weeks ago, # ^ |   +69 And you expected "a + b — c" kind of problem?
 » 3 weeks ago, # |   +18 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.
•  » » 3 weeks ago, # ^ |   0 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.
•  » » » 3 weeks ago, # ^ |   +10 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)
 » 3 weeks ago, # |   +94
•  » » 3 weeks ago, # ^ | ← Rev. 2 →   +2 meanwhile specialists today: " i am superman!!!"
 » 3 weeks ago, # |   0 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.)
•  » » 3 weeks ago, # ^ |   +5 End questions in div 3 are not 1700-1800. More like 2000-2400.
•  » » » 3 weeks ago, # ^ |   +9 End is relative :)
 » 3 weeks ago, # |   +15 The queue time almost does not exist! Thanks for the great round!
•  » » 3 weeks ago, # ^ |   -17 well there are 40+ pages on queue so...
•  » » » 3 weeks ago, # ^ |   +12 40 pages = 2-4 min of queue
•  » » » 3 weeks ago, # ^ |   +3 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.
 » 3 weeks ago, # |   +166 What div.1 and div.4 have in common for me: having nothing to do for about half an hour before the end.
•  » » 3 weeks ago, # ^ |   0 ayaya that made me laugh but its mutual
•  » » » 3 weeks ago, # ^ |   0 Thx! That's why I chose Codeforces. It's a good website to learn English and get contribution as well.
 » 3 weeks ago, # |   +6 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.
 » 3 weeks ago, # |   +12 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!!!
•  » » 3 weeks ago, # ^ |   +6 Congratulations. Keep this motivation, and you will be successful.
•  » » 3 weeks ago, # ^ |   0 Well done! Now make sure you won't get hacked :(
•  » » 3 weeks ago, # ^ |   -25 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)
•  » » » 3 weeks ago, # ^ |   +9 Bro chill. No need to report him to CIA.
•  » » » 3 weeks ago, # ^ |   +5 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
•  » » 10 days ago, # ^ |   0 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
 » 3 weeks ago, # | ← Rev. 2 →   +15 I think the order was a little unbalanced. It should be A C B D E G FORA C B D G E F
•  » » 3 weeks ago, # ^ |   0 OR A C B D G F E
•  » » » 3 weeks ago, # ^ |   0 I dont think so F was the most difficult problem acc to me
•  » » 3 weeks ago, # ^ |   +6 A C B D E G F seems to be the order of difficulty according to the AC counts.
•  » » 3 weeks ago, # ^ |   +5 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.
•  » » » 3 weeks ago, # ^ |   +1 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
•  » » » » 3 weeks ago, # ^ |   0 Damn, knew it was some trivial pattern I was missing. Thanks!
•  » » » » » 3 weeks ago, # ^ |   +3 I also didn't find a pattern at first, so I did a dfs search to find the solution.
•  » » » » » » 3 weeks ago, # ^ |   0 Can you explain further how can dfs be used to find pattern ?
•  » » » » » » » 3 weeks ago, # ^ |   0 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.
•  » » » » 3 weeks ago, # ^ |   0 Isin't this the solution of G.
•  » » » » » 3 weeks ago, # ^ |   0 He asked G :)
•  » » 3 weeks ago, # ^ |   0 A B C E D F G
•  » » 3 weeks ago, # ^ |   0 In my opinion it's A C B D F E G
•  » » 3 weeks ago, # ^ |   0 If you are a Newbie,I think ACBDGEF is better(But it is ACM-ICPC so it doesn't matter)
 » 3 weeks ago, # |   0 Finally I reached purpilll!!! Plz keep holding div4!!!
 » 3 weeks ago, # | ← Rev. 2 →   +1 Problem of long queue has improved a lot wrt last div1/2 contest!
 » 3 weeks ago, # |   0 nice problems, especially E. looking forward for more such contests and problems.
•  » » 3 weeks ago, # ^ |   -10 sire, please explain E to me. Couldn't understand editorial properly enough.
 » 3 weeks ago, # |   0 When you solve 4 problems in div3, but here you solve one......
 » 3 weeks ago, # | ← Rev. 2 →   0 I like problem A. It is easy but interesting and has an educational value.
»
3 weeks ago, # |
Rev. 4   +78

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

###### Problem A
Problem A - Tutorial
Problem A - Solution
###### Problem B
Problem B - Tutorial
Problem B - Solution
###### Problem C
Problem C - Tutorial
Problem C - Solution
###### Problem D
Problem D - Tutorial
Problem D - Solution
###### Problem E
Problem E - Tutorial
Problem E - Solution
###### Problem F
Problem F - Tutorial
Problem F - Solution
###### Problem G
Problem G - Tutorial
Problem G - Solution
•  » » 3 weeks ago, # ^ |   0 thank you
•  » » 3 weeks ago, # ^ | ← Rev. 3 →   +11 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.
•  » » 3 weeks ago, # ^ |   0 Thank you so much，mogul!
•  » » 3 weeks ago, # ^ |   0 For G you can reduce by 4 and then handle 3 cases
•  » » » 3 weeks ago, # ^ |   0 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.
•  » » 3 weeks ago, # ^ |   0 Thank you!Really concise and to-the-point editorial.
•  » » 3 weeks ago, # ^ |   0 Thank you very much
 » 3 weeks ago, # |   +21 I loved Problem G! It reminded me of one of my favorite problems on Codeforces: 24 Game
 » 3 weeks ago, # |   +1 Hi everyone! I uploaded screencast of this contest by this link (Solved all problems in 48 minutes!).
 » 3 weeks ago, # |   +3 Hey which approach in problem E would cause MLE?
•  » » 3 weeks ago, # ^ |   +4 I used a set to store all possible sums, which caused MLE.
•  » » » 3 weeks ago, # ^ |   0 Ohh then I think space complexxity with O(n^2) will cause MLE
•  » » » 3 weeks ago, # ^ |   +8 My workaround was to only store possible sums $\leq max$ and that passed.
•  » » 3 weeks ago, # ^ |   0 This solution got MLE, submitted to PyPy 3 for t in range(int(input())): n = int(input()) a = list(map(int,input().split())) PST = [0 for i in range(n+1)] for i in range(1,n+1): PST[i] = PST[i-1]+a[i-1] special = {-1} for i in range(1,n+1): for j in range(i+1,n+1): special.add(PST[j]-PST[i-1]) ans = 0 for x in a: ans += 1 if x in special else 0 print(ans) I switched to C++ so I could use a bitset<8000*8000> instead.
•  » » » 3 weeks ago, # ^ |   +16 for all i <= n we have a_i <= n so you don't need to save sums > n.
•  » » » » 3 weeks ago, # ^ |   +8 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.
 » 3 weeks ago, # | ← Rev. 2 →   +15 problem set was great. and I think your experiment has become successful. Today There is no Inqueue problem.
 » 3 weeks ago, # |   +12 Since I was tester in this round I was not able to participate. But I used the time to write an unofficial editorial
 » 3 weeks ago, # |   +13 The problems were easy but very interesting!
 » 3 weeks ago, # |   +35 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.
•  » » 3 weeks ago, # ^ |   0 Yes. this is unbelievable. By participating div2 or div3 one can be hardly rated like this. so I think Mike should change his strategy.
•  » » » 3 weeks ago, # ^ |   0 Yes, I think so.
•  » » 3 weeks ago, # ^ |   0 If we could solve all questions in 47 mins, he definitely deserves expert
•  » » » 3 weeks ago, # ^ |   +4 I'm just taking rank1 as an example. I mean maybe the strategy should be changed a little.
 » 3 weeks ago, # | ← Rev. 2 →   0 It seems that we can't view other's source after the contest?UPD: it's ok now
 » 3 weeks ago, # | ← Rev. 2 →   0 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?
 » 3 weeks ago, # |   -10 Thank you for hosting div4 and I encourage you to do so again in the future.
 » 3 weeks ago, # |   +8 I think it could've been div3 if one more difficult problem was added, and 1-2 current problems removed?
•  » » 3 weeks ago, # ^ | ← Rev. 2 →   +4 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 :)
•  » » 3 weeks ago, # ^ | ← Rev. 3 →   +27 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.
•  » » » 3 weeks ago, # ^ |   0 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.
•  » » » 3 weeks ago, # ^ |   0 G was Div2 B at most. Answer was trivial
 » 3 weeks ago, # |   0 how is it possible to have runtime error on c++ 11, but not on c++ 17, when someone uses only vector?
•  » » 3 weeks ago, # ^ |   0 happened with me once when i had not included header file
 » 3 weeks ago, # |   0 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
 » 3 weeks ago, # |   -9 Not satisfied with the order of problems!!!
•  » » 3 weeks ago, # ^ |   -10 With me, the G problem is easier than the F and E, but I couldn't solve it in time:((
•  » » » 3 weeks ago, # ^ |   0 Exactly!
 » 3 weeks ago, # |   +9 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.
 » 3 weeks ago, # |   +9 Thanks MikeMirzayanov for 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.
 » 3 weeks ago, # |   0 Why am I in practice mode, and how do I hack?
•  » » 3 weeks ago, # ^ |   0 Select somebody's submission and click hack!
 » 3 weeks ago, # |   0 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 :(((
•  » » 3 weeks ago, # ^ | ← Rev. 2 →   0 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!!
•  » » » 3 weeks ago, # ^ |   0 It will be easy for people to help if you add link to your submission.
•  » » » » 3 weeks ago, # ^ |   0 OKhttps://codeforces.com/contest/1352/submission/79569105 this is a sample of wrong answer with g++11https://codeforces.com/contest/1352/submission/79568929 this is a sample of Accepted with g++17both code are same
•  » » » 3 weeks ago, # ^ |   0 Make your own pow() function. Hope it will work.
•  » » » » 3 weeks ago, # ^ |   0 Thanks this approach worked. so problem is g++11 pow() precision?
•  » » » » » 3 weeks ago, # ^ |   0 As pow has return type double and you are typecasting it to integer then there might be precision loss.
 » 3 weeks ago, # | ← Rev. 2 →   +54 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
•  » » 3 weeks ago, # ^ |   +9 I too used the same approach :)
•  » » 3 weeks ago, # ^ |   0 I wrote a naive brute-force recursive function which seems to work fine. check this
•  » » 3 weeks ago, # ^ |   +5 I did not like this but simple like you. My submission
 » 3 weeks ago, # |   0 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.
 » 3 weeks ago, # |   +7 Although it's div4, I still think it's very difficult. Maybe I'm too bad.
•  » » 3 weeks ago, # ^ |   +2 Same bro, feel you!
•  » » 3 weeks ago, # ^ |   0 i felt so bad i tried some got TLE .... i usually solve 1 ques from div one
 » 3 weeks ago, # | ← Rev. 3 →   +10 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.
•  » » 3 weeks ago, # ^ | ← Rev. 3 →   +7 Yes even I feel the same, Last time I was able to solve 3 div3 questions but today I got struct at problem 2nd
•  » » 3 weeks ago, # ^ | ← Rev. 3 →   +14 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
 » 3 weeks ago, # |   +1 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?
•  » » 3 weeks ago, # ^ |   +3 $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.
•  » » » 3 weeks ago, # ^ | ← Rev. 2 →   +5 10^9 operations take 2 seconds or more.
•  » » » » 3 weeks ago, # ^ |   0 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.
•  » » » 3 weeks ago, # ^ |   0 n*n*logn is giving tle. I checked using map. So 10^9 not possible in 1s i think.
•  » » » » 3 weeks ago, # ^ |   +1 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
•  » » » » » 3 weeks ago, # ^ |   +3 I solved it using integer array instead of map. I was just checking whether n*n*logn passes or not.
•  » » » » » » 3 weeks ago, # ^ | ← Rev. 2 →   0 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 E UPD: Now i just ran my program with -O2 command for optimization. Sorry for such noobie question
•  » » » » » » » 3 weeks ago, # ^ |   0 The 3.5 seconds benchmark is from your computer?
•  » » » » » » » » 3 weeks ago, # ^ | ← Rev. 2 →   0 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
•  » » » » » » » » » 3 weeks ago, # ^ |   +1 Then it's not comparable. You can use codeforces custom test to make valid comparison
•  » » » » » » » » » 3 weeks ago, # ^ |   0 Thanks buddy
•  » » » » » 3 weeks ago, # ^ |   +1 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.
•  » » » » » » 3 weeks ago, # ^ |   +1 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.
•  » » » » » » » 3 weeks ago, # ^ |   +4 thanks! I have recently started with trees and graphs.I ll try to search it and learn more!
•  » » » » 3 weeks ago, # ^ | ← Rev. 2 →   0 No,In problem E n*n*logn using map solution works fine.I tried to hack my last submission,but failed.
•  » » » 3 weeks ago, # ^ |   +1 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.
 » 3 weeks ago, # | ← Rev. 2 →   0 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
 » 3 weeks ago, # |   +25 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
 » 3 weeks ago, # |   0 I have been satisfied with the contest
 » 3 weeks ago, # |   0 A very cool round. Keep the good work going, Codeforces administration team.
 » 3 weeks ago, # |   +3 Nice problem set
 » 3 weeks ago, # | ← Rev. 2 →   0 MikeMirzayanov 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.
 » 3 weeks ago, # |   -15 Screencast of this round. Click here , I was able to solve upto F.
•  » » 3 weeks ago, # ^ |   -6 Congratulations. I would have probably solved problem F had the contest duration been 2:15 hours instead of 2:00 hours.
 » 3 weeks ago, # |   0 I doubt,that one test included n=0
•  » » 3 weeks ago, # ^ |   0 I'm talking about last problem
•  » » » 3 weeks ago, # ^ |   0 Why do you think so? Constraints says n>=2
•  » » » » 3 weeks ago, # ^ |   0 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.
•  » » » » » 3 weeks ago, # ^ |   0 You are using a for loop until i<=ans.size(). It should be i
•  » » » » » » 3 weeks ago, # ^ |   0 thanks.
 » 3 weeks ago, # |   +35 Nice problems! My screencast of the round in Chinese bilibili 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?
•  » » 3 weeks ago, # ^ |   -17 i request you to screencast in english that will help lots of people who don't know chinese.
•  » » » 3 weeks ago, # ^ |   +10 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~
 » 3 weeks ago, # | ← Rev. 5 →   0 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.
•  » » 3 weeks ago, # ^ |   0 Can you show a link to your solution, thanks
•  » » » 3 weeks ago, # ^ |   0
•  » » » » 3 weeks ago, # ^ |   0 It's seem like you used 2 pointers.
•  » » » » » 3 weeks ago, # ^ | ← Rev. 2 →   0 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
•  » » 3 weeks ago, # ^ | ← Rev. 2 →   0 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.
•  » » » 3 weeks ago, # ^ |   0 Yep, seems right!
•  » » 3 weeks ago, # ^ |   0 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.
•  » » » 3 weeks ago, # ^ |   0 Yep me too and i think test 3 of cf is the same too.
 » 3 weeks ago, # |   0 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...
 » 3 weeks ago, # |   +8 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.
•  » » 3 weeks ago, # ^ |   +14 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.
•  » » 3 weeks ago, # ^ |   +10 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.
 » 3 weeks ago, # |   0 wow spookywooky becomes tester(cyan as well XDXD #worst year \ (•◡•) /)
 » 3 weeks ago, # | ← Rev. 2 →   0 Can somebody explain why this solution to problem E is getting TLED ?? 79579514 it runs I think within 1 sec locally.
•  » » 3 weeks ago, # ^ |   +1 Use vector instead of maps, and do not mp = mp1; instead do mp.swap(mp1)
 » 3 weeks ago, # |   0 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?
•  » » 3 weeks ago, # ^ |   0 The O(n^2) solution is accepted. Because the server can do 10 million operations in a second
•  » » » 3 weeks ago, # ^ |   0 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...
•  » » » » 3 weeks ago, # ^ | ← Rev. 2 →   0 Just try it. There are only +/- operations so that the server can do more operations in a second.
•  » » 3 weeks ago, # ^ |   0 Because for n=8000, n*n=6.4*10^7 and 10^8 iteration can easily pass on 1000ms
•  » » » 3 weeks ago, # ^ |   0 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
•  » » 3 weeks ago, # ^ |   +1 N^2 turns out to 64000000 < 10^8 which roughly takes 1000ms
 » 3 weeks ago, # | ← Rev. 2 →   +10 div 4 was a great round
 » 3 weeks ago, # |   0 Here is a video solution to this contest: https://www.youtube.com/watch?v=w11pV4hPCxE
 » 3 weeks ago, # | ← Rev. 5 →   0 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!
•  » » 3 weeks ago, # ^ |   -21 snitch
•  » » 3 weeks ago, # ^ |   +5 Their rating table is almost identical.
 » 3 weeks ago, # |   0 For C, I saw a very simple solution: (k-1)/(n-1) + k. Can you please explain why this works? Thank you :)
•  » » 3 weeks ago, # ^ | ← Rev. 3 →   0 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)
 » 3 weeks ago, # |   0 When the rank will be given?
 » 3 weeks ago, # |   -27 Не могу сдать решение задачи F Восстановление 01-строки на Паскале (на пример посылка №79588069) . При проверке и запуске на сайте программа останавливается при вводе тройки данных "2 0 0". Переставлял эту тройку данных внутри теста — далее её не идёт вывод ответа. На своём компьютере получаю верный ответ 000.
•  » » 3 weeks ago, # ^ |   -33 здоровья Вам и Вашему дельфину!
•  » » » 3 weeks ago, # ^ |   -25
 » 3 weeks ago, # |   +3 It is really really helpful.. please increase the frequency of such contests bcz it boosts the confidence of new comers .
 » 3 weeks ago, # |   +3 Finally a good contest... It will definitely boost our(newbie) confidence.Hey, codeforces if you are listening we need more contest like this...
 » 3 weeks ago, # |   +6 Have we got a conclusion that the server works ok and there will not be a long queue problem?
 » 3 weeks ago, # |   0 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.
 » 3 weeks ago, # |   0 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.
 » 3 weeks ago, # |   +5 @MikeMirzayanov Hi Mike. Please see this when you have time. https://codeforces.com/blog/entry/59228#comment-428171I knew it will happen like this. And I'm sure div 5 is comming.
 » 3 weeks ago, # |   0 Is this round rated? I didn't find it in the announcement above.
•  » » 3 weeks ago, # ^ |   0 yes it is rated.
 » 3 weeks ago, # |   0 Div.4 should happen more frequently. It will help a lot of beginners like me.
 » 3 weeks ago, # |   0 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)
 » 3 weeks ago, # |   0 is this contest not rated? Because it is written Contest finished but rating is not updated
•  » » 3 weeks ago, # ^ |   0 Updated now.Please be patient. System has to catch cheaters after the contest, which requires time.
 » 3 weeks ago, # |   0 I took part in the contest last night and I was unrated before the contest.Why am I still unrated now?
•  » » 3 weeks ago, # ^ |   0 Because the rating is yet to be distributed. Maybe in couple of hours it will be done. Until then you will be unrated.
 » 3 weeks ago, # |   0 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.
•  » » 3 weeks ago, # ^ |   0 Do not use ideone again.You must keep your code private.
•  » » 3 weeks ago, # ^ |   0 It's better to use vs code or codeblocks.
•  » » » 3 weeks ago, # ^ |   0 Codeblocks is my choice here although the best one I like is Sublime text 3
•  » » 3 weeks ago, # ^ |   0 Always prefer offline softwares for these competition because chances of plagarism increases, I personally suggest you Sublime text 3
 » 3 weeks ago, # |   0 I think this contest was more difficult than the previous Div.2 contest(My mind)
 » 3 weeks ago, # |   -10 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 ?
 » 3 weeks ago, # |   0 One question. Am I a trusted participant?(I have participated)
 » 3 weeks ago, # |   +22 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
•  » » 3 weeks ago, # ^ |   0 Damn 1012. Oof thats too much.
•  » » 3 weeks ago, # ^ |   0 It seems that for participants with rating lower than 100, during rating calculation they are considered 100.
 » 3 weeks ago, # |   0 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
 » 3 weeks ago, # |   +1 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.
•  » » 3 weeks ago, # ^ |   0 This contest is rated for new account. if your rating is less than 1400 (or you are a newcomer/unrated), then the round will be rated for you.
•  » » » 3 weeks ago, # ^ |   0 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
•  » » » » 3 weeks ago, # ^ | ← Rev. 2 →   0 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
•  » » » » » 3 weeks ago, # ^ |   0 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
•  » » » » » » 3 weeks ago, # ^ |   0 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
•  » » 3 weeks ago, # ^ |   0 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.
 » 3 weeks ago, # |   0 5000+fake accounts this time:(
 » 3 weeks ago, # |   0 The highest rating change user is definitely a new account made by another user. Isn't this a problem ?
 » 3 weeks ago, # |   +8 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 !
 » 3 weeks ago, # |   0 Hey, pls check the rating changes, there is a bug. The participants whose rating was 1500 got an increase in the ratings.
•  » » 3 weeks ago, # ^ |   0 Round was rated for unrated users. But some of them are new accounts made by pro coders :(
•  » » 3 weeks ago, # ^ | ← Rev. 2 →   +5 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.
 » 3 weeks ago, # |   +15 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.
•  » » 3 weeks ago, # ^ |   -19 So far the only people I have seen complaining about this are cyans and low experts. Coincidence? I think not.
•  » » » 3 weeks ago, # ^ |   0 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.
 » 3 weeks ago, # |   0 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.
 » 3 weeks ago, # |   0 I feel special now
 » 3 weeks ago, # |   0 Hi Mike! I have a question for you: will you do another div4 contest or this was the only one? Thanks! Luci
 » 3 weeks ago, # |   0 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?
 » 3 weeks ago, # |   0 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)!!
 » 3 weeks ago, # |   0 It was my first contest, and I really liked it. Got 2 accepted, but made minor mistakes in C & D. :(
 » 3 weeks ago, # | ← Rev. 2 →   0 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?
 » 3 weeks ago, # |   0 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.
 » 3 weeks ago, # | ← Rev. 2 →   0 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?
•  » » 3 weeks ago, # ^ |   0 It isn't because $a_2 = a_5 + a_6 = 4 + 3 = 7$ $a_3 = a_6 + a_7 + a_8 = 3 + 2 + 1 = 6$ $a_4 = a_6 + a_7 = 3 + 2 = 5$ $a_6 = a_7 + a_8 = 2 + 1 = 3$
•  » » » 3 weeks ago, # ^ | ← Rev. 9 →   0 Now I see, I misunderstood the statement, I thought it is `1≤l
 » 3 weeks ago, # |   0 What does D3A-D3D mean?
•  » » 3 weeks ago, # ^ |   0 This refers to a typical difficulty of problems in Div3 contest given as problems A to D. ie not very difficult problems.
 » 2 weeks ago, # |   0 For problem F n0=2,n1=0,n2=2 This test case is possible??
 » 10 days ago, # |   -8 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.