Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

### antontrygubO_o's blog

By antontrygubO_o, 6 months ago,

Hi everyone,

I am happy to announce that the 2020 Southeastern Europe Regional Contest will take place on May 23 at 10 am UTC+3. The link to the live results will be published here after the start of the competition.

Moreover, later this day, at 4 pm UTC+3, there will be the Grand Prix of Southeastern Europe based on these problems. Because of the Grand Prix, we are asking the official contestants not to discuss the problems in public.

After it, we will upload the contest to the gym and publish the editorial. We hope that you will enjoy the contest.

Good luck to all participants!

UPD. SEERC standings

UPD2. Congratulations to the winners!

Place Team Name Contestant 1 Contestant 2 Contestant 3 Problems Penalty
1 KhNU_OtVinta kilt_01 Stroustrup 13022001 8 1043
2 RAF Penguins Pajaraja milisav allllekssssa 8 1128
3 Echipa Dulce alexandra_udristoiu Stelutzu Usu 7 736
4 UAIC Endgame lungualex00 cristian1997 denis2111 7 837
5 KNU_stascool5 danya.smelskiy Sonechko stanislav.bezkorovainyi 7 1029
6 KhNU_GangBand dendi239 viskonsin Eikgrim 7 1230
7 cpu_goes_brrr muratt ykaya ekrem 7 1239
8 KhNURE_Energy is not over BigBag Barichek Mustang98 6 426
9 CodeBusters LucaSeri Hikori robxln 6 647
10 LNU Jackals BohdanPastuschak PetroTarnavskyi mshcherba 6 655

UPD3. Editorial

Thanks for your participation!

UPD4. The contest is available in gym:

• +169

 » 6 months ago, # |   +33 Shouldn't it be 2021?
•  » » 6 months ago, # ^ |   +21 No, SEERC 2020 was expected to be in Fall 2020. However, it was moved to Spring 2021.It is similar to the World Finals. World Finals 2020 will not be in 2020.
 » 6 months ago, # |   +10 How to solve A, C, G?
•  » » 6 months ago, # ^ |   +40 My solution to C:Make a triangle ABC, and a path of nodes 0..n with 0=A. Now connect each one of 1..n with one of A, B or C. The number of ways to color a prefix with color equal to A,B,C is in the form (x,y,0), and it transitions to (0,x,x+y) or (y,0,x+y), and 14 steps is enough to reach some (x,y,0) with x+y=k for all k <= 500.
•  » » 6 months ago, # ^ |   +20 A can be solved by analyzing the DP as a convex hull: for each prefix, what's the maximum value such that the last stack has depth $d$? We need to support the following 2 operations: take $f(x) \to f'(x) = max(f(x-1), f(x), f(x+1))$ (with the special case that $f'(-1) = -\infty$) and $f(x) \to f'(x) = f(x) + a_i x$. Both of these preserve the fact that the function is concave.We can maintain the function as a set of segments with $\Delta x = 1$, sorted in decreasing order by $\Delta y$; the first operation is inserting 2 segments of slope 0, and then deleting the steepest segment for $f'(-1)$, and the second operation can be handled with a lazy increment to the slope. If we use a priority queue, this code is extremely short: Code#include int main() { using namespace std; ios_base::sync_with_stdio(false), cin.tie(nullptr); int N; cin >> N; int64_t cur_slope = 0; priority_queue pq; int64_t ans = 0; pq.push(-cur_slope); pq.push(-cur_slope); ans += pq.top() + cur_slope; pq.pop(); while (N--) { int a; cin >> a; cur_slope += a; pq.push(-cur_slope); pq.push(-cur_slope); ans += pq.top() + cur_slope; pq.pop(); } cout << ans << '\n'; return 0; } Funnily enough, I wrote essentially the exact same code in 2015 for a USACO Camp problem (haybales, Day 3). The problem was as follows:Given an array of integers, find the minimum number of operations to make it non-increasing, where each operation can increment or decrement one value. Code#include using namespace std; typedef long long ll; int main() { int N; cin >> N; priority_queue s; ll y = 0; for(int i = 0; i < N; i++) { ll v; cin >> v; y += v; s.push(-v); s.push(-v); y += s.top(); s.pop(); } cout << y << '\n'; return 0; } In fact, the answer to SEERC A is exactly the answer to haybales on the $N+1$ prefix sums of the costs. Does anyone have an intuitive/combinatorial explanation? Is it LP duality or something?
•  » » » 6 months ago, # ^ | ← Rev. 2 →   +20 It's LP duality, indeed. We have mentioned that in the editorial, as well (although without much proof). The problem that you are mentioning is the classical problem for the "slope trick" technique (link). Also, this is a relevant problem (the same as you mentioned, maybe?). The two problems are actually equivalent. I think it's really interesting how different solutions to this problem leverage different ways to analyze and solve "slope trick", especially the reduction to minimum cost flow.
•  » » 6 months ago, # ^ |   +30 G: Just walk along the outside of the region following right-hand-rule. You just need to be able to efficiently jump to the next left-turn along your current segment (if it exists), which you can get by preprocessing the perpendicular segments in a persistent data structure. This is efficient because the size of the boundary of the region is linear. The editorial mentions an upper bound of $O(n \alpha(n))$ segments on the outside, but I believe I have a tighter bound: each right-turn (convex vertex) must correspond to the end of the segment so there are at most $O(n)$ right-turns. Furthermore, we make exactly 4 more right turns than left turns, so the total number of turns/segments we use must be $O(n)$ as well.
 » 6 months ago, # |   0 I've seen some solutions in K that have just one SOS pre-computation. Does anyone want to explain them?
•  » » 6 months ago, # ^ |   0 I'm not sure about other solutions, but one observation we made (and didn't use) is that the problem guarantees the number of 0's is at most 9, so that directly gives you an upper bound of approximately $d/3$ without having to consider the other cases.
•  » » » 6 months ago, # ^ |   +10 That’s true, but doesn’t that change once you start replacing question marks with 0/1?
•  » » » » 6 months ago, # ^ |   +20 You can avoid it, either replace the ? with 1 or keep it as ?, but knowing that any solution should have a 0 there.
•  » » » » 6 months ago, # ^ |   +20 (Assuming the number of 0's is at most 9)Try to replace each question mark with 1 if possible, but otherwise just keep it a question mark. After that, just replace all the remaining question marks with 0, because if we can't replace any question mark with 1, they must all be 0.
•  » » » » 6 months ago, # ^ |   +20 We can prefer replacing ?s with 1s. If it's not possible, we can leave it as ? instead of changing it to 0, because those will be equivalent. That way, the number of 0s you have to casework over doesn't increase.
 » 6 months ago, # |   +27 There's also a sweet interactive table provided by BigBag
 » 6 months ago, # |   +9 Why is aleksa purple in the table
 » 6 months ago, # |   0 Could anyone help me on Problem F? I cannot understand why dp transition on editorial makes sense.let dp[i][j] = (the number of output sequences b such that bi = hj)why dp[i][j] = sum(dp[i-1][0], ... , dp[i-1][j]) ?
 » 7 weeks ago, # |   +13 The editorial says that the problem H can be solved by "divide & conquer" in $O(n\log n + (q + n)\cdot b)$.Could anyone give me some details of the solution?(Sorry for my poor English.)
•  » » 6 weeks ago, # ^ | ← Rev. 2 →   +20 Probably I have the idea. Based on the conclusion we got before, to get the answer we can just divide the numbers in two part by the number of '1' bits.Consider how we answer all the queries completely included in the range $[l,r]$. Let $\textit{mid}=\lfloor(l+r)/2\rfloor$ and recursively solve the queries that completely included in $[l, mid]$ or $[mid+1,r]$, then the remaining queries we divide them into two parts. For the left part we record $b$ information at each position, and for the right part we process left to right by the right point of queries and keep the $b$ information during scanning. Because we record each position $O(\log n)$ times and each time we cost $O(b)$ time, so total complexity is $O(nb\log n)$.Actually if we want to reach the better time complexity, all we need is just one more thing. Notice that "record $b$ information at each position" is no need, because we just wonder the left points of the queries. So record the position we need instead of all of them. Now we get the $O(n\log n+(q+n)\cdot b)$ solution.My Code Here