### Zlobober's blog

By Zlobober, 10 months ago, translation, ,

Hi everybody,

Lasts Sunday there was a 15th Moscow Team Olympiad, high school students competition based in Moscow that is an elimination contest for All-Russian Team Olympiad. This contest is prepared by Moscow Olympiad Scientific Committee that you may know by Moscow Open Olympiad, Moscow Olympiad for Young Students and Megapolises Olympiad (rounds 327, 342, 345, 376, 401, 433).

Round will be held at 11:05 UTC on Monday and will last for 2 hours. Each division will consist of 6 problems.

Problems are prepared Andreikkaa, sender, Flyrise, -__-, kraskevich, wilwell under supervision of your humble servant with great help of GlebsHP, _meshanya_, Endagorion and Helen Andreeva.

Discussing problems with anybody who was a participant of Moscow Team Olympiad is strictly prohibited and may be a reason for disqualification.

Good luck everybody!

UPD: Thanks everybody for participation, congratulations to round winner!

Div1 winners:

Div2 winners:

Editorial will be published today after a while.

UPD2: Editorial!

•
• +240
•

 » 10 months ago, # |   -71 Is it rated?
•  » » 10 months ago, # ^ | ← Rev. 2 →   -47 Is it rated?It's rated!
•  » » » 10 months ago, # ^ |   -33 Every time when I wrote a comment "Is it rated?".. there is always someone to reply ""Every time I see comment "Is it rated?". Yes, it is."" :D
•  » » » » 10 months ago, # ^ | ← Rev. 3 →   -39 Every time when I wrote a comment "Every time I see comment ""Is it Rated?"" " there is always a reply "Every time when I wrote a comment "Is it rated?".. there is always someone to reply ""Every time I see comment "Is it rated?". Yes, it is."" :D" Is it rated?It is rated!
•  » » » » » 10 months ago, # ^ |   -22 Anyway, i'll downvote you for asking the question.
•  » » 10 months ago, # ^ |   -52 yAs iT iS rAtEd
•  » » 10 months ago, # ^ |   +23 Old way to get downvotes man be creative like me! I'm the master of downvotes in CF you can see my blogs or my comments to learn more about downvotes
•  » » » 10 months ago, # ^ |   -10 :D what differ to me if I get downvote or not.. Actually I never care about to be down voted..
•  » » » 10 months ago, # ^ |   +6 Arabs don't have short.
•  » » » » 10 months ago, # ^ |   0 Dude we have short but we don't wear them
 » 10 months ago, # |   +36 Recent contests were nice for me because I'm in UTC+8. Another great rated round is coming, good luck to all of you.
 » 10 months ago, # | ← Rev. 2 →   +25 212 = 441
•  » » 10 months ago, # ^ | ← Rev. 2 →   +54 Mind = blown
 » 10 months ago, # |   0 I had just done a contest yesterday xD
 » 10 months ago, # |   +9 Yap, two Consecutive contests in two Consecutive days. It's really amazing. :)
•  » » 10 months ago, # ^ |   +13 That too with two Div1 contests in two days. I was sad that I was unable to give yesterday's round, but seems fine now.
 » 10 months ago, # |   -35 Heylooo guyzzz .... is it RatEd ??????????
 » 10 months ago, # |   +10 Great!
•  » » 10 months ago, # ^ |   0 Can't compete this contest :(
•  » » » 10 months ago, # ^ |   0 orz
 » 10 months ago, # |   -59 The timing could have been better, as Indian college students mostly have classes till 5 PM .
•  » » 10 months ago, # ^ |   +47 So?
 » 10 months ago, # |   +16 Good luck to all the participants
 » 10 months ago, # |   0 A great time for chinese students again!
•  » » 10 months ago, # ^ |   +3 I think so.
•  » » 10 months ago, # ^ |   0 why?
•  » » » 10 months ago, # ^ |   0 because we in the UTC+8，and its just evening.
 » 10 months ago, # |   -13 Let us hope for too much hacks :)
 » 10 months ago, # |   -8 GL & HF
 » 10 months ago, # |   -8 Hope the problem statement will be short like yesterday round...
 » 10 months ago, # |   +17 Scoring distribution?
•  » » 10 months ago, # ^ | ← Rev. 2 →   +18 Their history also shows that no scoring has been ever announced.
 » 10 months ago, # |   0 WTF!! Can't see the problems
 » 10 months ago, # |   +2 will my rating change if I have one WA and Tle in the contest but no correct submission?
•  » » 10 months ago, # ^ |   +14 yes
 » 10 months ago, # | ← Rev. 3 →   0 :)
 » 10 months ago, # |   +5 I don't know Russian but i want to know the puns!
•  » » 10 months ago, # ^ |   +3 You are still waiting for somebody to explain you the puns? You could have already started learning Russian!
 » 10 months ago, # |   -13 Why there are only Div2 and Div3 contest?
•  » » 10 months ago, # ^ |   +8 Are you considering the contest TooNewbie?
 » 10 months ago, # |   0 What surprised me first was that “Why is the name list so LONG?"
 » 10 months ago, # |   -25 Click HereAnd the go to profile/submissions ;) you will magic!
 » 10 months ago, # |   0 A query regarding the judge..The output was 0, I displayed 00. Wrong answer.. why? aren't they the same thing..If I have calculated my output and there is still some input left which can be taken, is it possible I don't take it and directly display my result. (it is a normal take an array and do something question, not 't' times one.)
 » 10 months ago, # |   +14 What is pretest 9 in E?
 » 10 months ago, # |   0 WHAT IS DIV1D PRETEST 10 AHHH
•  » » 10 months ago, # ^ |   +5 Make sure you are not overcounting the subarrays. Try this test case: n = 3, a = [2, 4, 4].
•  » » » 10 months ago, # ^ |   0 answer is 2?
•  » » » » 10 months ago, # ^ |   0 Yes.
•  » » » » » 10 months ago, # ^ |   0 I see that you had WA10 in contest but you managed to fix it. Is there any other case that you had to fix before getting AC?
•  » » » » » » 10 months ago, # ^ |   0 Maybe overflow? I had only this issue with my code fixing which got me AC. I hope this won't fail the systest. :P
 » 10 months ago, # |   +14 How to solve F?
•  » » 10 months ago, # ^ | ← Rev. 3 →   +34 First, convert princes to nodes, and princesses to edges. You can show if the set of edges is a valid solution if and only if it is a psuedoforest (https://en.wikipedia.org/wiki/Pseudoforest ). So, it suffices to find the max weight pseudoforest.It turns out this is a matroid, so adding edges greedily works. All we need is an efficient way to check that each connected component has at most one cycle.
•  » » » 10 months ago, # ^ | ← Rev. 2 →   +8 Apparently my first submission tried to do this but I used = instead of |= in dsu. I think replacing it will make it correct. Have to wait after systest to submit it though.UPD : It got accepted.
•  » » 10 months ago, # ^ |   +28 lewin is absolutely correct, though this approach may be described from a different point of view without matroid theory.Consider a princess that is the best match for both of her princes. In an optimal solution this princess should be covered with an edge (otherwise we may force one of her princes to marry her and it will be at least the same profitable). It turns out that we may remove such princess from a graph (adding her value to the answer) and contract two her princes into a single super-prince having the union of edges of the original princes. It's easy to prove that it is an equivalent transformation.It leads to exactly the same solution that uses DSU to keep contracted princes.
 » 10 months ago, # |   0 How to DIV2C?
•  » » 10 months ago, # ^ |   0 Hint : What is the number with maximum sum of digits?
•  » » 10 months ago, # ^ |   0 Note that numbers up to 10^9 have at most 9 digits. So the maximum we can add to a number is 9x9 = 81 (putting 9 in every digit).Therefore we can just bruteforce 100 numbers (just to be safe) from n-100 to n checking if each one of them + the sum of the digits equals n.
•  » » » 10 months ago, # ^ |   +1 that's exactly what i did..... first time solved div2 C..... hurraayy! But B not solved xD
•  » » » 10 months ago, # ^ |   0 Yep exactly what I did. Arbitrarily put an lower limit of n-100. Although if there is a proper solution or a proof for it I would like to know.
•  » » 10 months ago, # ^ | ← Rev. 2 →   0 My incredibly overcomplicated approach is this: We can represent any number x as a0 + 10a1 + 102a2 + ... + 10nan. If we add a number's digits to itself, we will obtain a number k = 2a0 + 11a1 + ... + (10n + 1)an.Let's fix a0, a1, a2, a3, a4 = 0, and try all possible combinations of (a5, a6, a7, a8), generating all 104 integers k = (105 + 1)a5 + (106 + 1)a6 + (107 + 1)a7 + (108 + 1)a8 and storing them in a map. Then, we can fix a5, a6, a7, a8 = 0, then try all combinations of (a0, a1, a2, a3, a4) in the same way. For every integer k generated in this step, we can just check if n - k exists in the map we created before.Complexity: O(105log(105)).
•  » » » 10 months ago, # ^ |   0 Hi I was trying something similar. But why do you fix First five numbers?My submission
•  » » » » 10 months ago, # ^ |   0 We should minimize 10x + 10y, subject to x + y = 9. (10x = number of integers generated in the first step, 10y = number of integers generated in the second step.)
•  » » » 10 months ago, # ^ |   0 I tried exactly the same, it's like a diophantine equation. But, i didn't know how to solve it whitout bruteforce all the combinations, O(109) in the worst case.Why check n-k?
•  » » 10 months ago, # ^ | ← Rev. 3 →   +3 Let consider sum(x), sum(x) is the sum of the digits of the number xx + sum(x) = nx = n - sum(x)it's mean that you can just do bruteforce by the sum of the digits.Let maintain current sum as cursum, if sum(n - cursum) = cursum, we add n - cursum to our answerComplexity O(log(n) * maxsum)
 » 10 months ago, # |   +11 Am i the only one who solved the first task using dp???
•  » » 10 months ago, # ^ |   0 I did it too, much easier to code :P
•  » » 10 months ago, # ^ |   +1 After 2 wrong submisssions, I give up greedy and solve A with DP.
•  » » 10 months ago, # ^ |   +3 me too.
•  » » 10 months ago, # ^ |   +3 You're not alone :D
 » 10 months ago, # |   +1 Best contest ever. :)) I have never passed D. :))
 » 10 months ago, # |   +24 clicked the submit button 7secs before end of the contest, but it was not submitted. Now this thing has happened to me twice on cf.Just a suggestion, but maybe cf should consider accepting submissions for 10 extra seconds after the contest? As server is usually slow at the end of contest, this should not benefit people submitting just after contest.
 » 10 months ago, # |   +4 How to solve DIV2 E?
 » 10 months ago, # |   0 What was the hack for Div 1 C?
•  » » 10 months ago, # ^ |   0 I was hacked on the case when I tried to set to some letter that it should be capitalized don't paying attention that this letter can be already marked as a letter that cannot be capitalized.
•  » » 10 months ago, # ^ |   0 I failed in test case 62 31410790 4 5 2 1 5 2 1 4 2 2 3 2 2 5 I reduced 5 to satisfy 5->4 but did not reduce 3 so 3->5 became unsorted. My solution got accepted by running the recursion twice 31414586.I think the accepted solution is still incorrect. If there are three items I need to be reduced instead of two then I need to run the recursion 3 times. I guess there are no test case of such scenarios.
 » 10 months ago, # |   +58 How can Div1.F be solved in 9 minutes?I think more difficult problems are better.
•  » » 10 months ago, # ^ | ← Rev. 2 →   +54 Maybe the author just wants to see if there is anyone doesn't see the f problem from beginning to end
 » 10 months ago, # | ← Rev. 2 →   0 Div1 A is exactly same problem to Atcoder Regular Contest 034 B (http://arc034.contest.atcoder.jp/tasks/arc034_2 [old Atcoder contest, Japanese]), so I managed to solve in 2 mins. I think even copy-pasting the submission of this problem can lead to AC of today's Div1 A.
•  » » 10 months ago, # ^ |   -62 Unrated contest :P ?
•  » » » 10 months ago, # ^ |   +18 But I think the effect is very small, so it will be rated. This problem statement is in Japanese, so it seems >95% people didn't see this problem in participants of this contest. In addition, it seems >95% people who saw this problem didn't realize the problem, which this problem is already published in 3-years-ago AtCoder problem.
 » 10 months ago, # |   +36 Is there anyone who understood Div1B?
•  » » 10 months ago, # ^ |   -6 It took me hours to understand D , I thought I am not understanding it because I am a newbie.
 » 10 months ago, # | ← Rev. 2 →   0 Why after adding sort(a+1,a+n+1) to my submission it fails on test#1 on TLETLE#7 31410864TLE#1 31411210UPD : Already found
 » 10 months ago, # |   0 So to me, the key was understanding problem statement. I almost failed at Div2 D(Div1 B) but somehow managed to guess what authors meant. However, I completely failed at understanding Div2 E(Div1 C). Redefined 'Lexicographical order' was way too difficult and confusing.
 » 10 months ago, # |   +5 div1b, div1c, div1d = [div1c, div1d, div1b]
•  » » 10 months ago, # ^ |   +12 div1b was pretty easy . maybe like div2b
•  » » » 10 months ago, # ^ |   +3 Div2B is usually a task that could be submitted by average expert/candidate master in something like 10 minutes. Maybe I'm dumb but I didn't manage to find solution in ~30min while contest and ~30mins after.
•  » » » » 10 months ago, # ^ |   0 well i solved it in 11 minutes so it was like a div2B to me
 » 10 months ago, # |   -6 Am I the only one who used segtree + binary search on div2 D?
•  » » 10 months ago, # ^ | ← Rev. 2 →   +3 I too used a SegTree. Not Binary seaching though. Was really blown when I saw the actual solution!
•  » » 10 months ago, # ^ | ← Rev. 2 →   +5 why binary search? I maintained the rightmost position of zero in one segment tree and count of ones in an interval in another segment tree. So, the answer is just 1 plus count of number of ones present before the rightmost position of zero.
•  » » 10 months ago, # ^ |   +4 I used BIT+binary searchI thought it would fail as number of iterations were > 1e8,but it still passed in 218 ms :D :D
•  » » » 10 months ago, # ^ |   0 xD mine passed in 608 ms
•  » » » 10 months ago, # ^ |   0 I thought i was the only person used O(nlog^2n) algorithm in the world...XD Luckily, it didnt FST....
•  » » » 10 months ago, # ^ |   0 Am I the only one how solved it with Disjoint Set Union :)
•  » » » » 10 months ago, # ^ |   0 Can you explain how you did it with dsu??
•  » » 10 months ago, # ^ |   0 I just keep tracking on the rightmost consecutive X's and my solution passed in 156ms :)
 » 10 months ago, # |   +7 How to solve div2 E ?
•  » » 10 months ago, # ^ | ← Rev. 3 →   +19 Build a graph on letters which should be updated together. If the strings are different, there is only one pair of letters, which decides that the previous string is lex smaller than the next one.123124Add edge 4->3 to the graph, which means, that if you capitalize 4, you have to capitalize 3 too.125124You must capitalize 5 and you can't capitalize 4.In the end run dfs from every letter you must capitalize. Check that the letter which can't be capitalized, was not capitalized.I also checked special case1245124Which gives no immediatelly.
•  » » » 10 months ago, # ^ |   +6 pdwd Your comment helps me a lot to solve the problem.. thanks for sharing your idea :)
•  » » » » 10 months ago, # ^ |   +2 You're welcome!
•  » » » » » 10 months ago, # ^ |   +1 it's my pleasure to be so :)
•  » » 10 months ago, # ^ |   0 2-sat.
•  » » » 10 months ago, # ^ |   0 I do not remember 2 sat solution exactly but I know that strongly connected components were involved. For this problem, we have DAG (edges are from higher letters to lower).
 » 10 months ago, # |   +5 nice contest but really d was translated soooo bad
 » 10 months ago, # |   0 It seems like there are a lot of people failed the first system testcase of Div1C (including me T_T).
 » 10 months ago, # |   +12 Unlocking new bandage: FST Master.
•  » » 10 months ago, # ^ |   +29 That's me!
•  » » 10 months ago, # ^ |   0 Magolor orzzzz
 » 10 months ago, # |   -26 It's friendly to Chinese
 » 10 months ago, # |   +19 WoW!So many guys solve all the problems,You are so great The solution size of F seems so short,amazing!
 » 10 months ago, # | ← Rev. 4 →   +46 Problem almost the same as F was used in this contest in Petrozavodsk as problem A in 2012.Surpisingly, team Moscow SU T@pirenock: Evstropov, Ivlev, Pyaderkin was 12th in that contest, having two incorrect attempts at problem A :)This is the link to its statement.
•  » » 10 months ago, # ^ |   0 access denied, fix pls
•  » » 10 months ago, # ^ | ← Rev. 2 →   +142 Can't tell for Gleb and Michael, nontheless, I should have participated in that contest as a training around 2013. Of course I didn't remember this problem until this moment, otherwise we wouldn't have taken it in Codeforces round :)Almost 6 years is a long time period. Not sure if it is possible to remember all problems since you have started participanting in a programming contest. This problem in particular was suggested for a contest as an easier version of wilwell course work.PS so to me seems like a notorious coincidence.
 » 10 months ago, # |   +4 Where is div2 rating update?
 » 10 months ago, # |   0 In div2 B, why we don't need to calculate the difference between elements of multiset, just calculate the number%m and push it in vector array or map to count it's size?
•  » » 10 months ago, # ^ | ← Rev. 2 →   0 because (a — b) % m = (a % m) — (b % m) (and + m if it is negative). We save numbers (a, b) which have same remainder (x). a % m = x and b % m = x => (a — b) % m = x — x = 0 (that's we need). And it works for all pairs {a, b} if they have same remainder.
 » 10 months ago, # |   0 Can someone please elaborate how to solve Div.1 F? Thanks!
•  » » 10 months ago, # ^ |   +8 Editorial will appear soon, but you can refer to this comment tree right now.
•  » » » 10 months ago, # ^ |   +10 Thanks a lot!
 » 10 months ago, # |   0 How to solve Div1D or Div2F ??
•  » » 10 months ago, # ^ |   +17 start placing the numbers in decreasing order on the array now for each number that you put find out how many new intervals you can choose which contains this number . now its obvious that these intervals cannot include any of the already placed numbers (you can find the bound easily by std::set) now for each j that the current number & pow(2 , j) = 0 find the first place after and before the current place that number y & pow(2 , j) = 1 . now you have two intervals . just some conditions and AC
•  » » » 10 months ago, # ^ |   +8 Thanks a lot ...
•  » » » » 10 months ago, # ^ |   +13 youre welcome
•  » » » 10 months ago, # ^ |   +8 I think my solution is basically the same thing as what you described. Is Nlog^2N supposed to pass, or is there a more optimal solution?
•  » » » » 10 months ago, # ^ |   0 Mine was pure
•  » » » » » 10 months ago, # ^ |   0 It can be optimized to n log max easily with a pre calculation that for each bit and place we store the next and previous 1
 » 10 months ago, # | ← Rev. 2 →   +16 Am I the only one who doesn't like large problem statements.
 » 10 months ago, # |   +6 I still didn't get the problem Div2D? :(
 » 10 months ago, # |   0 Still no tutorial yet...
 » 10 months ago, # |   0 For DIV2 D,it's more hard to read than write.
 » 10 months ago, # |   +8 life sucks