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, mingaleg, 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!
Is it rated?
It's rated!
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
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"
It is rated!
Anyway, i'll downvote you for asking the question.
yAs iT iS rAtEd
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
:D what differ to me if I get downvote or not.. Actually I never care about to be down voted..
Arabs don't have short.
Dude we have short but we don't wear them
Recent contests were nice for me because I'm in UTC+8. Another great rated round is coming, good luck to all of you.
212 = 441
Mind = blown
I had just done a contest yesterday xD
Yap, two Consecutive contests in two Consecutive days. It's really amazing. :)
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.
Yes, it is rated.
Great!
Can't compete this contest :(
orz
The timing could have been better, as Indian college students mostly have classes till 5 PM .
So?
Good luck to all the participants
A great time for chinese students again!
I think so.
why?
because we in the UTC+8,and its just evening.
GL & HF
Scoring distribution?
Their history also shows that no scoring has been ever announced.
will my rating change if I have one WA and Tle in the contest but no correct submission?
yes
I don't know Russian but i want to know the puns!
You are still waiting for somebody to explain you the puns? You could have already started learning Russian!
Why there are only Div2 and Div3 contest?
Are you considering the contest TooNewbie?
What is pretest 9 in E?
WHAT IS DIV1D PRETEST 10 AHHH
Make sure you are not overcounting the subarrays. Try this test case: n = 3, a = [2, 4, 4].
answer is 2?
Yes.
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?
Maybe overflow? I had only this issue with my code fixing which got me AC. I hope this won't fail the systest. :P
How to solve F?
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.
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.
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.
How to DIV2C?
Hint : What is the number with maximum sum of digits?
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.
that's exactly what i did..... first time solved div2 C..... hurraayy! But B not solved xD
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)).
Hi I was trying something similar. But why do you fix First five numbers?
My submission
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.)
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?
Let consider sum(x), sum(x) is the sum of the digits of the number x
x + sum(x) = n
x = 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 answer
Complexity O(log(n) * maxsum)
Am i the only one who solved the first task using dp???
I did it too, much easier to code :P
After 2 wrong submisssions, I give up greedy and solve A with DP.
me too.
You're not alone :D
Best contest ever. :)) I have never passed D. :))
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.
How to solve DIV2 E?
What was the hack for Div 1 C?
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.
I failed in test case 62 31410790
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.
How can Div1.F be solved in 9 minutes?
I think more difficult problems are better.
Maybe the author just wants to see if there is anyone doesn't see the f problem from beginning to end
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.
Unrated contest :P ?
But I think the effect is very small, so it will be rated.
Is there anyone who understood Div1B?
Why after adding
sort(a+1,a+n+1)
to my submission it fails on test#1 on TLETLE#7 31410864
TLE#1 31411210
UPD : Already found
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.
div1b, div1c, div1d = [div1c, div1d, div1b]
div1b was pretty easy . maybe like div2b
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.
well i solved it in 11 minutes so it was like a div2B to me
Am I the only one who used segtree + binary search on div2 D?
I too used a SegTree. Not Binary seaching though. Was really blown when I saw the actual solution!
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.
I used BIT+binary search
I thought it would fail as number of iterations were > 1e8,but it still passed in 218 ms :D :D
xD mine passed in 608 ms
I thought i was the only person used O(nlog^2n) algorithm in the world...XD Luckily, it didnt FST....
Am I the only one how solved it with Disjoint Set Union :)
Can you explain how you did it with dsu??
I just keep tracking on the rightmost consecutive X's and my solution passed in 156ms :)
How to solve div2 E ?
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.
123
124
Add edge 4->3 to the graph, which means, that if you capitalize 4, you have to capitalize 3 too.
125
124
You 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 case
1245
124
Which gives no immediatelly.
P___ Your comment helps me a lot to solve the problem.. thanks for sharing your idea :)
You're welcome!
it's my pleasure to be so :)
2-sat.
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).
nice contest but really d was translated soooo bad
It seems like there are a lot of people failed the first system testcase of Div1C (including me T_T).
Unlocking new bandage: FST Master.
That's me!
Magolor orzzzz
It's friendly to Chinese
WoW!So many guys solve all the problems,You are so great The solution size of F seems so short,amazing!
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.
access denied, fix pls
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.
Where is div2 rating update?
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?
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.
Can someone please elaborate how to solve Div.1 F? Thanks!
Editorial will appear soon, but you can refer to this comment tree right now.
Thanks a lot!
How to solve Div1D or Div2F ??
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
Thanks a lot ...
youre welcome
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?
Mine was pure
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
I solved it in almost the same manner as from the recent 1418G - Three Occurrences. My code here : 95019408
Am I the only one who doesn't like large problem statements.
I still didn't get the problem Div2D? :(
Still no tutorial yet...
For DIV2 D,it's more hard to read than write.
life sucks