Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

### awoo's blog

By awoo, history, 5 years ago, translation,

Hello Codeforces!

On October 12, 17:05 MSK Educational Codeforces Round 30 will start.

Series of Educational Rounds continue being held as Harbour.Space University initiative! You can read the details about the cooperation between Harbour.Space University and Codeforces in the blog post.

The round will be unrated for all users and will be held on extented ACM ICPC rules. After the end of the contest you will have one day to hack any solution you want. You will have access to copy any solution and test it locally.

You will be given 6 problems and 2 hours to solve them.

The problems were prepared by Ivan BledDest Androsov, Vladimir vovuh Petrov, Mike MikeMirzayanov Mirzayanov and me.

Good luck to all participants!

Congratulations to the winners:

Rank Competitor Problems Solved Penalty
1 irkstepanov 6 141
2 SPFA_THE_BEST_ALGORITHM 6 169
3 KrK 6 199
4 chemthan 6 200
5 Shik 6 214

Congratulations to the best hackers:

Rank Competitor Hack Count
1 jhonber 75:-6
2 halyavin 31:-8
3 Zaher 6:-2
4 Khaled_Mohamed 4:-1
5 silicon_lover 2

123 successful hacks and 96 unsuccessful hacks were made in total!

And finally people who were the first to solve each problem:

Problem Competitor Penalty
A Barichek 0:01
C eddy1021 0:08
D unused 0:14
E irkstepanov 0:44

UPD: Editorial is published

• +139

 » 5 years ago, # | ← Rev. 3 →   +14 Why isn't it on the main page?UPD: Now it is on the main page.
 » 5 years ago, # | ← Rev. 2 →   -26 Don't HACK ME, uwi!
 » 5 years ago, # |   +17 Why there are so many people talk about uwi[user:uwi] when an educational round begin? I DONT think you will get an ACCEPTED just because of no hacks from others.Is it a joke?
•  » » 5 years ago, # ^ |   -12 You don't know uwi? Check thisYou (yaowan).
•  » » » 5 years ago, # ^ |   0 Sure I know who uwi is, because I GOT A HACK from uwi just before...I(cai de kou jiao...)
•  » » » » 5 years ago, # ^ |   0 You dalao...... I can't understand English well.... I (chizaoyaowan) QwQ
 » 5 years ago, # |   +8 Great!
•  » » 5 years ago, # ^ |   +6 Great!
•  » » » 5 years ago, # ^ |   +1 Great!
•  » » » » 5 years ago, # ^ |   +3 Great!
•  » » » » » 5 years ago, # ^ |   +9
 » 5 years ago, # |   -14 Is all educational round is unrated??
•  » » 5 years ago, # ^ |   +4 Yes, the goal of Educational round is rather to practice than to compete
•  » » 5 years ago, # ^ | ← Rev. 2 →   -29 The round will be unrated for all users and will be held on extented ACM ICPC rules.All Educational Round held on ACM ICPC rules.UPD:Educatonal Round for educating your mind. F**c logic!
 » 5 years ago, # |   -34 what is the subject of this round?graph?greedy???what?
•  » » 5 years ago, # ^ |   +13 Physics.
 » 5 years ago, # |   0 what the C question Saying?? i don't get it....!!
•  » » 5 years ago, # ^ |   0 "that is, if the current column is j, then he will find minimum i such that ai, j = 1" see if we take the current value of i and calculate the score for current j it may happen that we can do better if we escape this 'i' and move to another 'i' and start at this (suppose that at some position we have continuous 1's and so, that position will be better for our answer).so, to move at that position we have to escape some i's which have 1 (i.e. we need to invert them).Now, it may happen that various i's may give same contribution to our answer and fro all those we have to choose that i for which we can minimize inversion ! Clearly greedy solution works here!
•  » » 5 years ago, # ^ |   0 It can be solved using precount for each column and greedy algorithm. The main difficulty in this task is to carefully check when you meet 1. You can see my solution for reference.
 » 5 years ago, # | ← Rev. 3 →   0 does anybody know how does the 5th test look like at problem E? L.E:i thought that is 2 have the same score,they should recive the same grade,but i was wrong
 » 5 years ago, # |   0 My best round ever! Shame that it was educational and unrated(( (also toughest b ever)
 » 5 years ago, # |   0 Why my idea is wrong on test 24?my wrong code is hereThe idea is using binary search to get the answer
•  » » 5 years ago, # ^ |   -10 you don't need binary search dude
•  » » » 5 years ago, # ^ |   0 what does it mean?
•  » » » » 5 years ago, # ^ |   -17 it means that you can solve the problen without using it
•  » » 5 years ago, # ^ |   +10 You can't use binary search for this problem because the objective function (the length of the substring in your case) is not monotonic. Consider the example: 00111100. You can make balanced strings of lengths 2, 4, 8 but not 6.
•  » » » 5 years ago, # ^ |   0 so are data weak?
•  » » » 5 years ago, # ^ |   0 // 1 2 3 4 5 6 7 8 // id // 0 0 1 1 1 1 0 0 // string s from you // 1 2 2 2 2 2 3 4 // the sum of zeros from substring( 1 , i ); // 0 0 1 2 3 4 4 4 // the sum of ones from substring( 1 , i ); int left=0,right=n/2; while(left>1; if(this length of substring can be found in string s ) left = mid+1; } so I just find out the answer "4" that is right I think.
•  » » » » 5 years ago, # ^ |   0 The answer is 8.
•  » » » » » 5 years ago, # ^ |   +1 I saw it...So binary search is surely wrong.
•  » » 5 years ago, # ^ |   +1 I also had wrong answer in test 24. I realized this after the contest finished :/. you can't do binary search. try this case 10 1110000011
 » 5 years ago, # |   +5 will there be any editorial?
 » 5 years ago, # |   +3 How to solve B ?
•  » » 5 years ago, # ^ | ← Rev. 5 →   0 change array a[]==0 to -1.find prefix[]=prefix sumfind two indices of maximum difference for which it is same value.take example. 10011 -1 -1 1prefix[]=1 0 -1 0there are two.so between these two maximum length found...!! my submission:31249578
•  » » » 5 years ago, # ^ |   0 Thanks Doaremon , But I think This is called prefix array and not suffix Correct me if I am Wrong.
•  » » » » 5 years ago, # ^ | ← Rev. 2 →   0 Haha.i don't know why i used suf[] at that time.....
•  » » » » » 5 years ago, # ^ |   0 happens.
•  » » » 5 years ago, # ^ |   0 How did you know u can solve it using this way ? Does it have a name , this method ?
•  » » » » 5 years ago, # ^ |   0 by solving more and more problems...triggered this logic in mind suddenly...
 » 5 years ago, # | ← Rev. 3 →   +7 I couldn't AC my O(n*sqrt(n)) approach for problem F.Test cases were very strong!
 » 5 years ago, # |   +1 How to solve D ??
•  » » 5 years ago, # ^ | ← Rev. 4 →   +17 If k is even, then no solution because you always make 1 (main call)  + 2·m calls where m is the number of times you pass from condition 1. If k is odd, then there exists a solution if k is less than the maximum number of calls.You can solve the problem recursively by calling a function that takes the current subarray endpoints and k and the integer to starting filling the array with in this subarray (if the integer is x and the subarray size is L, then you will fill it with the integers x, x + 1, ..., x + L - 1. These integers are the subarray values. The main call will be f(0, n, k, 1).If k = 0, then put all the numbers sorted in the subarray so you do not make any mergeSort() call. Otherwise, split the subarray according to the rules. The left part will take the largest subarray values and the right part will take the smallest values. In this case, we guarantee that we will make 2 mergeSort() calls. Then you call f() for the left part giving it k - 2 to be maximum number of mergeSort() calls it can use and it will return the remainder of k - 2 (the unused calls). Then you call f() for the right part giving it this remainder. Finally, you return what the right part returns back. For a solution to exist, the returned value of the main call must be equal to 0
•  » » » 5 years ago, # ^ |   0 Thanks
 » 5 years ago, # |   +5 How to solve F?
•  » » 5 years ago, # ^ | ← Rev. 3 →   +6 Let's reverse string and build suffix array. Since we have sorted suffixes, string 'a' will be a LCP of some consecutive suffixes in suffix array, next we should get LCP array (lcp[i] = lcp of suffix[i] and suffix[i + 1] when i and i + 1 indexes in sorted order). If we represent LCP array as columns along axis, our task transformed to 'find rectangle with maximum area', and it can be solved with two stacks: for each lcp[i] find nearest left and right index j, that lcp[j] < lcp[i], after that we should relax the answer with lcp[i] * (rightJ — leftJ), because there are (rightJ — leftJ) strings, that have lcp[i]. So the last question is how to handle forbidden cells? we should merge all lcp (in lcp array) into one between each two consecutive non-forbidden cells.PS. If you not familiar with suffix structures, I hope it can be solved with the same aproach with replacing suffix array by hashing+binary search for sorting suffixes.
•  » » » 5 years ago, # ^ |   +1 How can you sort the suffixes with hashing???
•  » » » » 5 years ago, # ^ | ← Rev. 2 →   +19 To compare two strings you need to find LCP (binary search LCP and check that hashes are equal) and just compare the next characters. (each compare will be in O(logN) so sort will be in O(nlog^2n))
•  » » » 5 years ago, # ^ |   0 5 ababa 00100 in this test case LCP[] = {1,3,0,2,0} then how can i calculate final answer from here?
•  » » » » 5 years ago, # ^ |   0 We always should try to relax the answer with each separate suffix itself (in this case it will be ababa), so it's special test case.
•  » » » » » 5 years ago, # ^ |   0 yes got it. but O(nlog^2n) gives TLE. http://codeforces.com/contest/873/submission/31433595
 » 5 years ago, # |   0 Can Someone Explain me how rajat1603 solved B ?
•  » » 5 years ago, # ^ |   0 logic is same as my sol just implemented in easier way....
•  » » 5 years ago, # ^ | ← Rev. 3 →   +3 You just need prefix sum to solve this question and realize the following : initially sum = 0add 1 to sum if you encounter a '1' subtract 1 from sum if you encounter a '0' Suppose you are at current index 'i' and your Current sum is S. You are encountering this sum S for the first time. you map i to S. i.e, map[S] = i... Now suppose for some later index J you encounter S you just update ans as max(ans, j — map[S]) because if you observe carefully you need the best possible sum to be 0.if you have current sum as 0 at index 'i' then you keep updating the answer with 'i' + 1
 » 5 years ago, # |   +6 Could you please look into unknown verdicts for hacks 360797 and 360798?
•  » » 5 years ago, # ^ |   0 Problem is fixed, hacks will be rejudged by the end of hack phase.
•  » » 5 years ago, # ^ |   0 Could you please explain to me how does hacking work?
 » 5 years ago, # |   +5 How to solve E?I tried with a DP approach but it didn't work.
•  » » 5 years ago, # ^ |   +3 Good day to you,Well hope it won't be wrong, since it is not "proved yet" :)Firstly, sort all "heights" (yet still remember their original position to be able to reconstruct at the end). Now, it is pretty easy to assign a value to each position (it is the height on the position minus the height on previous position [potentionaly 0]).So not lets consider how would "brute-force" solution work? Well kinda simple.. just try EVERY triple in the array (check whether the x*2>=y is fine) and then take MAXIMUM from these (what is maximum is written in the "rules" — note tht the rightmost is always best diploma :) ). Now as you can see, it will obviously TLE, anyway as you can also see, it is just O(N3) which is not bad.So now we can "simply" focus on reducing of the third cycle. As the other two iterations are fixed, we know pretty well, where the segment (if any) for the third cycle might be. EXAMPLE: N==10, i=7,j=9, we know the length of first segment is 2 and of second is 1, so the length of third segment must be between 1 and 2 (which begins on position 5 or 6). We are interested in the biggest number there so we can use some "RMQ" structure, which could get it. One way is for-example Sparse Table which can get maximum in O(1) making the total complexity O(N2).So in short: Iterate with two (the best) diplomas and find the third by RMQ.Good Luck And have Georgeous Day ^_^Hope it was a little bit undestandable and hope I didn't lead you wrong way ^_^
•  » » » 5 years ago, # ^ | ← Rev. 2 →   +8 "it will obviously TLE" — not so obviously, I got AC with brute force only suitable indices in third cycle (Code) And this solution can be optimized more if brute force only suitable indices in second cycle also.
•  » » » » 5 years ago, # ^ |   +3 Good day to you ^-^Well seems you are right (yet I would still be a little bit afraid). Seems taking only "interesting" seps makes it "766 149 050", which might be suitable (not sure what (whether) are your other optimalisations)So well thank you, seems it is a little bit easier approach ^_^GL & Have Nice Day
 » 5 years ago, # |   0 Can someone explain to me how does hacking work?
 » 5 years ago, # |   0 can anyone please explain how to solve E?
 » 5 years ago, # |   0 When will the editorial be published?
 » 5 years ago, # |   0 Auto comment: topic has been updated by awoo (previous revision, new revision, compare).