### ch_egor's blog

By ch_egor, 2 years ago, translation,

Hi everybody,

This Sunday there will be a 16th 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 Metropolises Olympiad (rounds 327, 342, 345, 376, 401, 433, 441, 466, 469, 507).

Round will be held at 10:05 UTC on Sunday and will last for 2 hours. Each division will have 6 problems.

Problems are prepared gritukan, Glebodin, Andreikkaa, qoo2p5, mingaleg, Flyrise, _kun_, achulkov2, grphil, Sehnsucht, Aphanasiy, Sender, DebNatkh, GreenGrape under my supervision with great help of GlebsHP, _meshanya_, Endagorion, Zlobober and Helen Andreeva.

Thanks to _kun_ for the round coordination and statement translation, and also thanks for MikeMirzayanov for systems codeforces and polygon, which was used to prepare problems of this olympiad.

Good luck everybody!

UPD1: The scoring distribution will be:

500 — 10001000 — 1500 — 2000 — 2500 for div. 1.

500 — 1000 — 1500 — 20002000 — 2500 for div. 2.

UPD2: Editorial

UPD3: Winners:

Div. 1:

Div. 2:

• +194

 » 2 years ago, # |   -52 will it be rated for any division?
•  » » 2 years ago, # ^ | ← Rev. 3 →   0 There is a separate round for div1 and div2.
 » 2 years ago, # |   +38 Unfortunately clashes with GP of Korea.
•  » » 2 years ago, # ^ |   +3 where is the contest "GP of Korea"?
 » 2 years ago, # |   0 unfourtunately that's on my school time :(
•  » » 2 years ago, # ^ |   +10 On Sunday? :o
•  » » » 2 years ago, # ^ | ← Rev. 2 →   +32 Yes, in arabic countries the firday is a day-off, not the sunday
•  » » » » 2 years ago, # ^ |   +42 Lol, this comment chain is a copy of this one from the first Moscow Team Olympiad held on Codeforces.Guess somethings never change xD
•  » » » » » 2 years ago, # ^ | ← Rev. 2 →   +13 \(0_0)/ 
•  » » » » 2 years ago, # ^ |   +20 i wish there a country where every day is off the school :PAnd Hii Bau :D
•  » » » » » 2 years ago, # ^ |   0 hi sguu
•  » » » » 2 years ago, # ^ |   0 not only Arabic countries , in Iran the friday is a day-off.
•  » » 2 years ago, # ^ |   +2 In many Chinese senior high schools, Saturday and Sunday are school time. ( >﹏<。)～
•  » » » 2 years ago, # ^ |   0 very real
 » 2 years ago, # |   +30 A Russian Olympiad clashing with open cup, why am I not surprised?
 » 2 years ago, # | ← Rev. 2 →   +68 We're going to write it tomorrow official and my team is really scared of Mr.GreenGrape in problemsetters
 » 2 years ago, # |   +14 Perfect time for Chinese users!
•  » » 2 years ago, # ^ |   -18 %%%
 » 2 years ago, # |   +22 Perfect time for Korean users, as the contest is in 7PM, and they can't take today's GP!
 » 2 years ago, # |   +6 GL&HF
 » 2 years ago, # |   -7 hope not a mathforces
 » 2 years ago, # |   -20 Really bad time for US users :(
•  » » 2 years ago, # ^ |   0 Just go back to sleep after the contest :)
•  » » 2 years ago, # ^ |   +10 Really good time for Chinese users :)
 » 2 years ago, # |   -19 is it rated?
 » 2 years ago, # |   +15 Perfect time for Chinese users.Thank you Codeforces!
 » 2 years ago, # |   0 The site has slowed down significantly.
 » 2 years ago, # |   +1 In Div 2 problem D, the time limit is very strict. Python solution not passing pretest 8 even after all possible optimisations.
 » 2 years ago, # |   0 Div2 D pretest 13?
•  » » 2 years ago, # ^ |   0 Yes, this one killed me too
•  » » » 2 years ago, # ^ |   0 Mine too gave WA on 13, using DFS. Bypassed it by using BFS. Probably recursion stack size was the issue.
•  » » » » 2 years ago, # ^ |   0 recursion stack size has never been an issue for me ON CODEFORCES.
•  » » » » 2 years ago, # ^ |   0 the same experience as yours,but my bfs was hacked because i didn't use priority_queue.
•  » » » 2 years ago, # ^ |   +6 I too got WA, solved using DFS!
 » 2 years ago, # |   +91 Interactive Problem and Binary Search again.
 » 2 years ago, # |   -6 What were the hacks on Labyrinth about?
•  » » 2 years ago, # ^ | ← Rev. 10 →   +25 Input20 7 3 6 5 2 ......* .****.* .****.* ....*.* **.**.* **.**.* **.**.* **.**.* **.**.* **.**.* **.**.* **.**.* **.**.* **.**.* **.**.* **.**.* **.**.* **.**.* **....* *******  Output47 for those who used a single queue.UPD: It seems that not everyone used a single queue failed on this test.
•  » » » 2 years ago, # ^ |   0 Then my D will fail systest
•  » » » » 2 years ago, # ^ |   -18 Careless boy
•  » » » 2 years ago, # ^ |   +5 I am using single queue but i pass this test
•  » » » » 2 years ago, # ^ |   +5 Same situation in my case.
•  » » » 2 years ago, # ^ | ← Rev. 2 →   0 Lol?I used a single queue and passed systests in 140ms.Could you elaborate on why was that supposed fail?
•  » » » » 2 years ago, # ^ | ← Rev. 2 →   +5 Your solution works cause you're checking for a better answer on if(lf[xx-DX][yy-DY] < lx) Which is pretty much the same thing as removing the if and making sure you visit the node with the least amount of horizontal moves as possible (i.e., by using a priority queue and sorting by increasing number of horizontal moves)
 » 2 years ago, # |   0 CSAcademy saved me on E with the geometry tool.
 » 2 years ago, # | ← Rev. 3 →   +61 yeah i managed to hack the Grandmaster last minute!!!
 » 2 years ago, # |   +83 After one hour of rocket science, I realised that answer for C is.sort(s.begin(), s.end()); cout<
•  » » 2 years ago, # ^ |   0 So the correct answer for asasas is aaasss, isn't it asasas better? First one has 8 palindrom substrings and the second one has 12.
•  » » » 2 years ago, # ^ |   0 First one also has 12
•  » » » 2 years ago, # ^ |   +3 First one has:aaasssaaaassssaaasss 12 in total.
•  » » » » 2 years ago, # ^ |   +2 Now I understand, thank you all. :)
•  » » » 2 years ago, # ^ |   0 both have 12. 3 as, 2 aas, 1 aaa and similarly for s.
•  » » » 2 years ago, # ^ |   0 No, first one too has 12 palindromic substrings..'a - 3 times, aa - 2 times aaa - 1 time, total - 6and similarly 6 for sss so, 12
•  » » » 2 years ago, # ^ |   0 It's 12 for both. Single character is also a palindromic substring.
•  » » 2 years ago, # ^ |   0 what is the correct approach to this problem?
•  » » » 2 years ago, # ^ | ← Rev. 4 →   +53 It is a correct approach, which can be proven.Basically the idea is that if you consider any palindrome, its both ends must have same character.This implies natural bound on the number of palindromes having end of character c occuring x times: x(x + 1) / 2.One can see, that sorted string reaches that bound exactly.
 » 2 years ago, # | ← Rev. 2 →   +22 I bet there will be lots of FST (failed system test) on Div1.B/ Div2.D, since lots people are using queue instead of priortiy queue, which will results in TLE. Though, it is not easy to hack them :(
•  » » 2 years ago, # ^ |   +11 Deque is enough, thought
•  » » » 2 years ago, # ^ |   0 Wait. I don't understand. Wouldn't the same element be put into queue for more than one time? Just like SPFA? Does anyone want to explain that to me?
•  » » » » 2 years ago, # ^ | ← Rev. 6 →   0 Usual 0-1bfs — deque + array that indicates visited cellsYou won't visit cell with better cost than first visit.First time (using 0-1bfs) — cell will be visited with L left moves and R right moves, all other times it will be L+k and R+k where k>=0P.S. I hope it understandable enough
•  » » » » » 2 years ago, # ^ |   0 So the cost will be different if you move vertically instead of horizontally, right? which means the cost in your queue can be not monotomous.
•  » » » » » » 2 years ago, # ^ |   +13 No, it will always be monotonous.The idea, is to push a vertex at back of deque if the weight is 1, and at the front of deque if weight of edge is 0. Since, there can be atmost two levels of weight in queue, it will always be monotonous.My submissionYou can read about it here
•  » » » » » » » 2 years ago, # ^ |   0 Oh! Use deque, then it is always monotonous! Such a neat application of deque! I got it. Thank you so much!
•  » » » » » 2 years ago, # ^ |   0 I didn't think of why you use a deque instead of queue. Now I get it. Thank you!
 » 2 years ago, # | ← Rev. 2 →   -139 I am eblan.
 » 2 years ago, # |   +14 whats the correct approach for div2 d?
•  » » 2 years ago, # ^ |   +22 0-1 bfs
•  » » » 2 years ago, # ^ |   0 I have done same but got TLE in pretest 8
•  » » » » 2 years ago, # ^ |   0 you used map, but it is slow here
•  » » » » » 2 years ago, # ^ |   0 So how to speed up my solution? using unordered_map ?
•  » » » » » » 2 years ago, # ^ |   0 Use 2d array
•  » » » » » » » 2 years ago, # ^ |   0 Thank you very much Numb! :)
•  » » » 2 years ago, # ^ |   0 So it's dijkstra
•  » » » 2 years ago, # ^ |   0 great idea numb!
•  » » » 2 years ago, # ^ |   0 so why does bfs fail ??
•  » » » » 2 years ago, # ^ | ← Rev. 9 →   +3 10 6 10 6 5 2 **.... **.**. **.**. **.**. **.**. **.**. **.**. ....*. .****. ...... usual bfs will find (8;3) with 5 lefts and 2 rights and won't go to (8;4)
•  » » » » » 2 years ago, # ^ |   0 If we were to use dijkstra's instead, do we sort the items in the priority queue based on the number of left moves, or the number of right moves, or does it not matter? And also, do we sort it in ascending or descending order?
•  » » » » » » 2 years ago, # ^ |   0 the number of left plus right moves, ascending order (firstly take the least)
•  » » » » » » » 2 years ago, # ^ |   0 thank you
•  » » » » » 2 years ago, # ^ |   0 so we should always go up or down first
•  » » » 2 years ago, # ^ | ← Rev. 2 →   0 By 0-1 bfs do you mean we will have to take n*m*4 states.I was doing the same.But I could not submit the code because of a bug I had in my code.But my code passes the test you have given above.
•  » » » » 2 years ago, # ^ |   0 Why 4nm?
•  » » » » » 2 years ago, # ^ | ← Rev. 2 →   -6 Because n*m states for each cell and 4 states for from which direction i entered to that cell.Otherwise if i take n*m states then it was not unique enough and creating conflict.
•  » » » » » » 2 years ago, # ^ |   0 Why do you need the information "from which direction i entered to that cell"?
•  » » » » » » » 2 years ago, # ^ |   +10 Yeah.The extra state is not needed.My code is giving correct answer without it.Thank you.
•  » » » » » 2 years ago, # ^ | ← Rev. 2 →   0 ignore
 » 2 years ago, # |   +8 I had RE 8 on D problem because of pragma pragma#pragma GCC optimize("Ofast") #pragma GCC optimize("no-stack-protector") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("unroll-loops") #pragma GCC diagnostic ignored "-Wunused-result" I think it can be a problem of new servers. MikeMirzayanov, can it be fixed?
•  » » 2 years ago, # ^ |   0 I also got RE 8.
•  » » » 2 years ago, # ^ |   0 I too got RTE on pretest 8
 » 2 years ago, # |   +38 how to solve F?
•  » » 2 years ago, # ^ |   0 Let dp(i) be the maximum length of a journey starting at position i. Then, dp(i) ≥ x iff there exists such j that i + x ≥ j, dp(j) ≥ x - 1 and s[j, j + x) matches either s[i, i + x) or s[i + 1, i + x + 1).
•  » » 2 years ago, # ^ | ← Rev. 2 →   0 You can get different and solutions with the following observation:There exists an optimal journey such that these conditions hold:1) The maximal length of a string in the journey is .2) The difference in lengths of two consecutive strings in the journey will always be 1.Mine didn't pass but maybe someone passed with such a solution.
•  » » » 2 years ago, # ^ |   +8 We believe shouldn't pass.Try thinking about solution :).
•  » » » » 2 years ago, # ^ |   0 It passes in 2.6 seconds. Turns out using a suffix array to help finding the groups of suffixes that have lcp >= i makes it a lot faster. http://codeforces.com/contest/1063/submission/44310989
•  » » 2 years ago, # ^ | ← Rev. 3 →   +34 My solution is . Not sure if it will pass.I am going to assume the string to be reversed.This way the strings in a journey are going to be increasing in length.We can prove that there always exists an optimal answer when ti has length i. Now, let dpi be the largest possible length, such that the last string ends at position i. Note that if we can have a valid length l ending at i, we can also have a valid length l - 1, so it makes sense to define such a dp state.We can binary search on dpi. For a length l, the second last string is either same as si - l + 1... i - 1 or the same as si - l + 2...i. We find the rightmost such string which doesn't intersect the last string, and check if this string could be used according to the dp state. Finding the rightmost possible second last string can be done using persistent segment tree in . Basically, we have a range on the rank in suffix array the secondlast string can belong to, and a maxmium possible rightmost index for the secondlast string as the constraints.
•  » » » 2 years ago, # ^ |   -8 It won’t :(Try to replace binary search with some monotonic observation.
•  » » » » 2 years ago, # ^ |   +6 Passed with small optimizations. Sad that both the accepted solutions have worse complexity.
 » 2 years ago, # | ← Rev. 2 →   -17 Time limit for Problem D is too strict :(
•  » » 2 years ago, # ^ | ← Rev. 2 →   0 Not at all. It can be solved in O(nm).
•  » » » 2 years ago, # ^ | ← Rev. 2 →   0 my solution is also O(nm) but i am using map which give me TLE on test 8
•  » » » » 2 years ago, # ^ |   +11 So your map don't have a log?
•  » » » » » 2 years ago, # ^ |   0 I am using map,pair> which is very slow When I get the idea why my solution is slow I am very late
•  » » » » » » 2 years ago, # ^ |   0 Each access is O(log(n)) time, which seem to be timing out under the current constraints. Instead, try using a 2D array of pairs, so that the time required for each access is constant.
•  » » » » » » » 2 years ago, # ^ | ← Rev. 2 →   0 Thanks! after replacing map with 2d array i passed the time limit but I got wrong answer on test 33. Do you have any idea why my solution is incorrect on test 33 http://codeforces.com/contest/1064/submission/44324094
 » 2 years ago, # |   +23 How to solve Div1 D?
•  » » 2 years ago, # ^ |   +13 Think of solution.
•  » » 2 years ago, # ^ | ← Rev. 2 →   -112 unrated!
 » 2 years ago, # |   0 My solution for Div2 D is failing on test 13. Could anybody help me where I am making a mistake? Thanks!!
•  » » 2 years ago, # ^ |   0 My approach it is the same, if u get the solution tell me
•  » » 2 years ago, # ^ |   0 The time limit is too strict, possibly due to recursion and stack size.
•  » » 2 years ago, # ^ | ← Rev. 2 →   +2 As far as I understand you did a dfs and checked the conditions and you dont visit the same place twice. However consider this......*.**.x.**x is where you are initially.lets say you can go left at most once and right at most twice.Then if you go left and go up twice and go right twice you will mark (0,2) as visited and when you come there again from (2,1) -> (2,2) -> (1,2) -> (0,2) you wont continue since it (0,2) is visited however you went right only once and if you continued you could go right.
•  » » » 2 years ago, # ^ |   0 Thanks for your help, got my mistake.
•  » » » 2 years ago, # ^ |   0 Can you please tell why this one got TLE at pretest 7? It is approximately same what you did using queue. https://ideone.com/7kZrsp Thanks!
•  » » » 2 years ago, # ^ |   0 Expected answer is 9. right?
•  » » » » 2 years ago, # ^ |   0 Yes
•  » » » 2 years ago, # ^ |   0 Thanks bro i got my mistake
•  » » » 2 years ago, # ^ |   0 So what's the correct approach to solve it using DFS? Thanks for pointing out the mistake though.
•  » » » » 2 years ago, # ^ |   +1 It's very hard to (if possible) because dfs doesn't have properties of shortest paths.
•  » » » » » 2 years ago, # ^ |   0 Ok Thanks that makes sense.
 » 2 years ago, # |   +1 What’s pretest 10 in div 2 E?
•  » » 2 years ago, # ^ |   +1 Probably something like 1 black and 29 white.
•  » » 2 years ago, # ^ |   0 Yeah I was getting wrong answer on pretest 10
•  » » 2 years ago, # ^ |   +17 n = 30, jury mostly assigns colors randomly.However there is a small twist: in all of jury tests (except for sample) if it is possible to assign a color, such that it makes impossible to separate points later jury will always do that :).
 » 2 years ago, # | ← Rev. 2 →   0 Div 2 Problem C was tricky. I can't prove solution correctness. Can anyone give me a proof ?
•  » » 2 years ago, # ^ |   +31 answer is just sorted s. if Nx is number of occurrences of x in s. then number of palindrome substrings because first and last letter of palindrome must be same. on the other hand this number is achieved when s is sorted.
•  » » » 2 years ago, # ^ | ← Rev. 2 →   -10 I am trying to understand this formula you stated.
•  » » » » 2 years ago, # ^ |   +1 is number of ways to choose substring so that it starts and ends with x
•  » » » » » 2 years ago, # ^ | ← Rev. 3 →   -24 Shouldn't it be (nx) * (nx — 1) / 2 then ? Number of ways of picking 2 things out of nx. (Combinations)
•  » » » » » » 2 years ago, # ^ |   +1 substring can have only 1 character
•  » » » » » » » 2 years ago, # ^ | ← Rev. 2 →   -11 Oh thanks! Got the same formula after accounting for substrings of length 1 (adding Nx to my formula)
•  » » » 2 years ago, # ^ |   0 I am still not able to understand this formula. The no. of palindromes in a string of length n having all characters equal to c will definitely be n * (n + 1) / 2 but how does that justify that summing over this expression over the frequencies of all chars in a string having more than one character gives an upper bound on the no. of palindromes that we can have in a permutation of the string ?
•  » » » » 2 years ago, # ^ |   +3
•  » » » » » 2 years ago, # ^ |   +1 That helped. Thanks. :)
 » 2 years ago, # |   -10 gag forces?
 » 2 years ago, # |   0 With new Judging infrastructure, I hope System testing would be a bit faster.So that i upsolve after that :)
 » 2 years ago, # | ← Rev. 2 →   +29 C and D combined made this the worst problemset in my opinion I've seen so far in codeforces.C was binary search. Nothing else, just binary search, just hidden behind a silly problem statement about lines. There's lots of complaints about every interactive problem being binary search and then we get new problems like this :/D was a math problem emphasizing exactly what I hate about most math problems. You just have to make a trivial observation (either n or the number of rounds is small), and then calculate stuff. Of course, the calculation isn't interesting either, It's just super annoying case handling.The especially annoying thing about D was that the last person can take just one candy, even if they have a sweet tooth. That adds nothing to the creative part of solving the problem, and around doubles the amount of case handling. Why was that there?In my recent memory I don't remember any problem worse than either of these, and now we got two of them on the same round :/
•  » » 2 years ago, # ^ |   -10 I 100% agree. Missed that sweet tooth — one candy case for 30 minutes during contest...
•  » » » 2 years ago, # ^ |   -18 Remembered comment of some cf user but can't find that comment. It was something like followF*ck math problems
•  » » 2 years ago, # ^ |   +73 Well, while I will agree that D had hard technichal part, I not very much agree with your complaints on C.You just needed to come up with cute binarysearch-like construction and the implementation is very short. If the problem was obvious to you -- just get AC in 5 mins and move on!
•  » » 2 years ago, # ^ |   +10 For me div1C was not trivial, and had a lot of challenges, not just "implement binary search". I don't think the geometrical construction was obvious at all.
 » 2 years ago, # |   +1 In problem D Div 2, why dfs not working ?? thanks
•  » » 2 years ago, # ^ | ← Rev. 3 →   +16 (edited) dfs won't work, because you can end up in a square with "wastefully expended left/right moves". Meaning, you could end up in the same square later with fewer left/right moves. What do you do at this point? If you reprocess the square and start doing dfs again from it, you will TLE for sure. If you don't reprocess the square, you might get WA if later on you fail to reach some square because you had wastefully expended left/right moves earlier.edit 2: or maybe dfs will work if you can do dfs in such an order that you never wastefully expend left/right moves?
•  » » » 2 years ago, # ^ |   0 thanks, baobab. I have found the mistake :)
•  » » 2 years ago, # ^ | ← Rev. 3 →   +5 Consider you started from vertex 'X' and at some point you are at vertex 'Y'DFS ensures that you visit every vertex only once so you won't come to vertex 'Y' again. But as the graph formed might be cyclic i.e. there can be multiple ways to reach a vertex 'Y' from 'X' and there can be a possibility that there is some shorter path to 'Y' that you'll miss.PS: Dijkstra :)
•  » » » 2 years ago, # ^ |   +5 Also: BFS
•  » » » 2 years ago, # ^ |   0 Dijkstra can be fast enough on C++ but on Java it apparently wasn't: https://codeforces.com/contest/1064/submission/44311014
•  » » 2 years ago, # ^ | ← Rev. 2 →   0 20 73 65 2......*.****.*.****.*..ox*.*..*..*..*..*..*..*..*..*..*..*..*..*..*..***....******** you may dfs to the point "x" from the path above and stop at the point "o", when you then dfs along the path below, you're blocked at the point "o" which is visited. You could have reached "x" but not. :) I also used dfs :) this case has been mentioned above(if it is shown unexpectly)
 » 2 years ago, # | ← Rev. 2 →   0 I got trolled by div2 C lol :/ Wrote 80 lines of buggy code...
•  » » 2 years ago, # ^ |   0 My solution in python: def ans(): n = int(input()) c = bin(n).count("1") ans = pow(2, c) print(ans) tc = int(input()) for _ in range(tc): ans() 
•  » » » 2 years ago, # ^ |   0 Oh sorry, I meant div2C. My solution for B was the same idea.
 » 2 years ago, # |   +47 Test 40 Div2D distroyed so many dreams :(
•  » » 2 years ago, # ^ |   +4 There goes my hopes of entering div1 :(
•  » » » 2 years ago, # ^ |   +7 wat is hope?
•  » » » » 2 years ago, # ^ |   0 form Red's point of view !Hope is a dangerous thing ! hope van drive a man insane from Andy's point of view !hope is a good thing, maybe the best of good things and no thing good ever dieyou choose to be realistic (Discussion), ok but don't try to make people give up their dreams/goals please !
 » 2 years ago, # |   +10 weak pretests in div2 D
 » 2 years ago, # |   +63 The Div1 problem E about lasers is beautiful in my opinion, thanks to the authors!
•  » » 2 years ago, # ^ |   +10 You are very welcome :)
 » 2 years ago, # |   +18 I guess that my solution to F has complexity O(n2.5)... I implemented O(n1.5·log(n)), but it turned out to be slower and more memory-eating, so I resubmitted older brute force, which passed with max time lower than one second.
•  » » 2 years ago, # ^ |   +12 WOW, and my solution failed!
•  » » » 2 years ago, # ^ | ← Rev. 2 →   +27 OK, OK, sorry, it's O(n1.5), just noticed some amortization.
 » 2 years ago, # |   0 I GOT TLE IN TEST 10,IN DIV 2 C MY SOLUTION time complexity in o(nlogn) but still it got timed out. is it due to slow input output?
•  » » 2 years ago, # ^ |   0 Actually it could be O ( N ). Flash sort!
 » 2 years ago, # |   0 Can somebody please help me finding why my code for DIV2 D gives a run time error?? CODE
 » 2 years ago, # |   +52 The difficulty curve was.. 98.9%, 75.2%, 73.7%, 5.9%, 2.1%, 0.4% (percentage of people who solved each problem)Perhaps codeforces should consider including problems solved by between 6% and 73% of participants???
•  » » 2 years ago, # ^ |   -8 Impossible
•  » » 2 years ago, # ^ |   +23 It was a bit... unexpected to us.We held a presolving of the moscow team olympiad, from which the problems are. And most of the teams got accepted all problems except problem corresponding to Div1F.So I was even worrying whether our Div1D and Div1E are a bit too easy.
•  » » » 2 years ago, # ^ | ← Rev. 2 →   +3 maybe the next time the presolvers group should contain not only red and orange coders, not only ROI prizers and ROI winners?
 » 2 years ago, # |   0 What's Test 27 in Div2 D?
 » 2 years ago, # |   0 Can someone explain why Div2 D Test 40 failed for me??44306721
•  » » 2 years ago, # ^ |   0 Just go left, straight up and down, then go right. You can visit all the free cell. 0-1 bfs can solve this problem. Because moving up and down costs 0, you should push one colomn into the queue at the same time when visiting a new cell.
•  » » » 2 years ago, # ^ |   0 but what is the issue with normal bfs even in normal bfs i am trying to find the node closest to a popped node so that the nearest nodes are reached first.
•  » » » » 2 years ago, # ^ |   +3 Normal bfs just visits the nodes as quick as possible. This means it may go left and right for several times and reach the limits. But it is possible that existing a path which is longer than the first one but turn left or right less. In this situation, bfs will visit a node that already been visited, and won't push the new node into the queue, leaving some of the nodes not visited. My code
•  » » » » » 2 years ago, # ^ | ← Rev. 2 →   0 Thanks zhujianan understood :)
 » 2 years ago, # |   +7 How to solve Div2 E??
•  » » 2 years ago, # ^ |   +1 Use binary search! Put x somewhere to the middle (from 1 to 999999999) and fix it (x=3, for example) and try (3,0) (save the color). Next try (3,500000000). If these two point have the same color next point you should try is (3, 750000000) if colors are different next point should be (3, 250000000). Beware of edges cases: one with all points with the same color and when another one only one color is different 44313158 (very bad code, sorry)
 » 2 years ago, # |   0 Can someone look into my solution for DIV 2 D problem 44308344 and tell me where I am going wrong. Thanks :)
 » 2 years ago, # |   +1 How would you guys come up with the solution for problem C, Div 2? And how would you test it to make sure that every time you sort the string’s characters you get maximum number of palindromes?
•  » » 2 years ago, # ^ |   +8 Sixth sense!
•  » » 2 years ago, # ^ |   +1 I manually checked it for random strings of length 10
•  » » 2 years ago, # ^ |   +13 I was trying something on paper and I suddenly saw that for aaaaab the count is much higher than its other permutations, once I realised that I could prove it easily as :suppose you are counting palindromes with a as it ends, now if you insert anything in between two a's, that may decrease count by 1. Hence all occurences of a character must be together.
 » 2 years ago, # |   +1 where is the editorial?
 » 2 years ago, # | ← Rev. 4 →   +5 DIV1 B: Suppose, system tests are weak. This solution based on simple BFS and single queue (not BFS-0-1) 44319324 passed all the tests. UPD: tests are not weak, my solution differs from BFS in visiting vertexes twice and more times.
•  » » 2 years ago, # ^ |   +5 I think this solution is right. It has right answer on my hack
•  » » 2 years ago, # ^ | ← Rev. 2 →   +21 This is equivalent to SPFA (or Bellman-Ford with queue). It is a correct shortest path algorithm, and although its worst case complexity is O(VE), practically it's very fast for most graphs.SPFA can be hacked by specially constructed graphs, but I don't know whether such graph exists given the restrictions of this problem. Also, since SPFA is not popular outside China, non-Chinese problem setter usually don't make anti-SPFA tests.Disclaimer: My solution used the same algorithm.
•  » » » 2 years ago, # ^ |   +18 Thanks for the information, didn't know neither about SPFA neither about Bellman-Ford. There is a reason to read something. Finally, found the difference between my solution and simple BFS: in my case one vertex can be visited once again, if there is better path found.
•  » » » 2 years ago, # ^ |   0 I've just known that some of the solutions implement BFS using deque instead of a queue, which allows them to keep the queue monotonous. Then the complexity is the same as a standard BFS — O(V + E), which is correct. However, I do think those solutions using queue is hackable, but there might not be anti-SPFA tests.
 » 2 years ago, # |   +1 Div2 D Time depends a lot on Compiler, same solution in c passed and c# TLE
 » 2 years ago, # | ← Rev. 2 →   0 It's possible to pass Div2 D using shortest path if you use a faster heap in C++... http://codeforces.com/contest/1064/submission/44318340
•  » » 2 years ago, # ^ |   0 Even built-in priority_queue worked fine for me. Here is my solution.
•  » » 2 years ago, # ^ |   0 simply use deque and it passes in tenth of your time.
 » 2 years ago, # |   0 How to solve Div2 F? Can this problem be solved with binary search？
 » 2 years ago, # |   0 Can anyone tell me why i am getting runtime error on pretest 8 44315444 Please help i am not getting the mistake
 » 2 years ago, # | ← Rev. 2 →   -6 Hey, ch_egor MikeMirzayanov _kun_, my submission 44312315 gave TLE during contest, but identical submission 44320638 gives AC now. Can anything be done about it?
•  » » 2 years ago, # ^ |   0 Nothing can happen now. Same thing has happened with me twice, but they don't re-evaluate our code after the contest. See the codes 37815677, 37820871. They are identical but one gave TLE during system testing while the other one passed after the contest. I also posted about it in a comment, but no one even cared to reply. I also messaged Mike on CF, but he also just ignored the message. Here is the link for the discussion.
•  » » 2 years ago, # ^ |   +5 Dude, your identical submission also nearly TLE'd. So the TLE during the contest seems reasonable. There is no reason to judge your solution again.
 » 2 years ago, # |   0 shorest solution I ever encountered: input();print(''.join(sorted(input();input()))) 
•  » » 2 years ago, # ^ |   +24
•  » » » 2 years ago, # ^ |   0 probably it is shortest for div 2 C?
•  » » » » 2 years ago, # ^ |   +16
•  » » » » » 2 years ago, # ^ |   0 did you write a script to find that?
•  » » » » » » 2 years ago, # ^ |   +17 noi just remember
•  » » » » » » » 2 years ago, # ^ | ← Rev. 2 →   0 Cool :)
 » 2 years ago, # | ← Rev. 2 →   0 The problem C in Div.2 is amazing!!!!!!
 » 2 years ago, # |   -10 what is this cugh
 » 2 years ago, # |   0 Is it possible to get the complete input for test #10 in div2D? I'm really curious what I did wrong in #44322132 and can't get it...
•  » » 2 years ago, # ^ |   0 Well nevermind, found my mistake.
 » 2 years ago, # |   0 BFS with one queue is fine for div2 D: 44322392
 » 2 years ago, # |   -17 Thank you for pretests, GreenGrape
•  » » 2 years ago, # ^ |   +42 Joke’s on you, but I was involved only in d1F.
•  » » » 2 years ago, # ^ |   0 You stole my rating and now you’re trying to steal my contribution
•  » » » » 2 years ago, # ^ |   +7 Funny, its the first time i have seen author trolling the participant xD
 » 2 years ago, # |   -13 So much math.
 » 2 years ago, # |   +23 Test 40 for Div2-D be like
 » 2 years ago, # |   0 How to solve Div 2 B i didn't able to find the approach
•  » » 2 years ago, # ^ |   0 Brute force solution for a from 0 to 20 and try to find a connection between a and the answer
•  » » » 2 years ago, # ^ |   0 This is a good tip in general, it's way easier to prove if something in particular works (or doesn't) rather than finding the solution itself
•  » » 2 years ago, # ^ | ← Rev. 2 →   0 just observe that since If i'th bit of a is 1, then if i'th bit of x is 0 or 1, in both cases i'th bit of is 1, and we are safe.But if i'th bit of a is 0, then i'th bit of x must be 0, i'th bit of will be 2,i.e, greater than 0. which will make greater than a.hence the answer is
•  » » » 2 years ago, # ^ |   0 Oh my god!I was just thinking what will I do with the minus sign in . Just that if I did I would have seen it. :(
•  » » » 2 years ago, # ^ | ← Rev. 2 →   0 But in case when ith bit of a=0 and x=0, will also give 0 which is equal to a right?
•  » » » » 2 years ago, # ^ |   +1 Yes, that's the point, if i'th bit of a is zero then i'th bit of x must be zero.
•  » » » » 2 years ago, # ^ |   +1 I made little mistake in my statement, edited that now !!
 » 2 years ago, # |   +16 DIV1 B:Suppose, system tests are weak.Solutions: 44298986 44296043 Test: 3 3 1 1 1000000000 1000000000 .** *** **. `Solutions have different answers: "1" and "2"("1" is correct answer).
 » 2 years ago, # |   0 In Div2 C,Can Anyone explain why the sorted String is the best answer.
•  » » 2 years ago, # ^ |   0 See this link: http://codeforces.com/blog/entry/62440?#comment-463988
•  » » » 2 years ago, # ^ |   0 Thanks
 » 2 years ago, # |   0 Hello, could you throw a link to the analysis of this round
 » 2 years ago, # |   0 Nice Contest overall! Thanks Codeforces.
 » 2 years ago, # | ← Rev. 2 →   0 T̶h̶e̶r̶e̶'̶s̶ ̶p̶e̶o̶p̶l̶e̶ ̶a̶s̶k̶i̶n̶g̶ ̶f̶o̶r̶ ̶t̶h̶e̶ ̶e̶d̶i̶t̶o̶r̶i̶a̶l̶.̶ ̶T̶h̶i̶s̶ ̶i̶s̶ ̶t̶h̶e̶ ̶e̶d̶i̶t̶o̶r̶i̶a̶l̶.̶ ̶I̶ ̶g̶u̶e̶s̶s̶ ̶t̶h̶e̶ ̶a̶u̶t̶h̶o̶r̶ ̶f̶o̶r̶g̶o̶t̶ ̶t̶o̶ ̶l̶i̶n̶k̶ ̶i̶t̶ ̶h̶e̶r̶e̶?̶ ̶̶h̶t̶t̶p̶s̶:̶/̶/̶c̶o̶d̶e̶f̶o̶r̶c̶e̶s̶.̶c̶o̶m̶/̶b̶l̶o̶g̶/̶e̶n̶t̶r̶y̶/̶6̶2̶4̶5̶5̶
•  » » 2 years ago, # ^ |   +11 I was busy and came home a few minutes ago.
•  » » » 2 years ago, # ^ |   0 Sorry I didn't realize editorial and announcement authors were different people
 » 2 years ago, # |   0 Sorry for this, but can anybody tell me how to view others code in gym? Maybe I need high rating or anything else? And I can't find any announcement about it.
 » 2 years ago, # | ← Rev. 2 →   -15 can someone explain why my solution for D is wrong?
 » 2 years ago, # |   0 I'm getting TLE when I'm not using if(visited[x][y]) continue; // for checking whether the node is visited before or not here is my code link https://ide.geeksforgeeks.org/bcROnzM4qJ
•  » » 2 years ago, # ^ | ← Rev. 2 →   0 It's possible for BFS (0-1 variant too) to have repeats of same element in (de)queue, so this is actually to be expected.For example, try drawing a "triangle" graph (three node cycle) to convince yourself. You will see that two of the nodes repeat.
»
2 years ago, # |
0

### Where are the winners?

 » 2 years ago, # |   0 i am looking for its tutorial.
 » 2 years ago, # |   0 ....................................
 » 2 years ago, # |   0 1654605415065460
 » 2 years ago, # |   0 can anyone help me with div2. D i tried floodfill but it got WA on test case 5 my approach now is to BFS but i get WA in test case 40 https://codeforces.com/contest/1064/submission/44454781
•  » » 2 years ago, # ^ |   0 See my comment here,it may help you
 » 2 years ago, # |   0 How to solve div 2 F? Will there be tutorial?
 » 2 years ago, # |   0 Can anyone please explain Problem B in div2?