Блог пользователя TheScrasse

Автор TheScrasse, 11 месяцев назад, По-английски

2151A - Incremental Subarray

Author: TheScrasse
Preparation: TheScrasse

Hint 1
Hint 2
Solution

2150A - Incremental Path

Author: TheScrasse
Preparation: TheScrasse

Hint 1
Hint 2
Solution

2151C - Incremental Stay

Author: TheScrasse
Preparation: TheScrasse

Hint 1
Hint 2
Solution

2150B - Grid Counting

Author: TheScrasse
Preparation: Dominater069

Hint 1
Hint 2
Hint 3
Hint 4
Hint 5
Hint 6
Solution

2150C - Limited Edition Shop

Author: TheScrasse
Preparation: TheScrasse

Hint 1
Hint 2
Hint 3
Solution

2150D - Attraction Theory

Author: Dominater069
Preparation: Dominater069

Hint 1
Hint 2
Solution Part 1
Hint 3
Hint 4
Hint 5
Solution Part 2

2150E1 - Hidden Single (Version 1)

Author: TheScrasse
Preparation: TheScrasse, Dominater069

Hint 1
Hint 2
Hint 3
Hint 4
Solution

2150E2 - Hidden Single (Version 2)

Author: TheScrasse
Preparation: TheScrasse, Dominater069

Hint 1
Hint 2
Solution

2150F - Cycle Closing

Author: TheScrasse
Preparation: TheScrasse, Dominater069

Hint 1
Hint 2
Solution

2150G - Counting Is Fun: The Finale

Author: satyam343
Preparation: satyam343

Solution
Разбор задач Codeforces Round 1053 (Div. 1)
Разбор задач Codeforces Round 1053 (Div. 2)
  • Проголосовать: нравится
  • +155
  • Проголосовать: не нравится

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

is there any greedy solution for div2 E?

  • »
    »
    11 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    I hope this code could help you^^

  • »
    »
    11 месяцев назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится +6 Проголосовать: не нравится

    Yes, here's how I did it:

    As editorial states, if Alice takes item $$$x$$$, she must also take all items $$$y \lt x$$$ that satisfy $$$pos_y \gt pos_x$$$. This condition is both necessary and sufficient.

    Now, the greedy solution is as follows: for each $$$i$$$ from $$$1$$$ to $$$n$$$, if $$$v_i \leq 0$$$, we should definitely not take it at this moment. Otherwise, let's find an unused item $$$j \lt i$$$ with the smallest $$$pos_j$$$ satisfying $$$pos_j \gt pos_i$$$. If no such item exists, the condition is already satisfied and we can simply add $$$v_i$$$ to our answer.

    Otherwise, if we ever end up taking item $$$j$$$, we will surely also take item $$$i$$$. Therefore, we can merge these two into a single item with $$$v' = v_i + v_j$$$ and $$$pos' = pos_j$$$. If $$$v' \gt 0$$$, we repeat this process again.

    Let me know if anything needs clarification.

    340848541

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I've solved E12 slightly differently from the editorial one, but couldn't prove why it works well.

I had rec(l, r, b) where [l, r) is the range that contains shuffled indexes, and b is the values that appear only in [l, r) shuffled indexes. And checked every value in b if it appears in [l, mid), [mid, r) or in both. and descended in to the part with greater size of b. At the end we have r — l == 1 and |b| = 1, and b[0] would be the answer.

Part that made my code work from WA1 on E2 was descending to the range with greater size of the b. So if it fails to find the answer in the range with the greater size of b, it will descend to other half. Currently I don't know why that works.

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +38 Проголосовать: не нравится

Is there any reason for disabling hacks in Div1A?

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +74 Проголосовать: не нравится

Got WA on div1D because I did cout << a[0]; instead of cout << a[0] % mod; for $$$n=1$$$. I guess it would have been better to include this example in samples as $$$a_i$$$'s are usually less than the mod value :(

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +21 Проголосовать: не нравится

Div2D was a great problem!

»
11 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится +3 Проголосовать: не нравится

A (too complicated) forward DP solution for Div2D:

$$$dp(i) = \text{# of partial valid colorings up to row }i$$$
$$$dp(1) = \binom{n-2}{a_0-2}$$$

(Must color the two extreme cells)

Since we can only color cells up to the (n+1)/2 row, we can compute this DP up to n/2.

Define c_i as the number of cells we colored so far. Then we can divide our previous colorings into 3: if we already colored the 2 columns i and n-i+1, if we colored exactly one of them, and if we colored none. If we colored none, we must color them now to satisfy conditions 2 and 3, and similarly for the other cases. This gives rise to the following DP formulation:

$$$dp(i) = dp(i-1) \cdot ((\text{ratio both colored}) \cdot \binom{n-c_i}{a_i} + 2\cdot (\text{ratio one colored}) \cdot \binom{n-c_i-1}{a_i-1} + (\text{ratio none colored})\cdot \binom{n - c_i - 2}{a_i-2})$$$

Where the ratios mentioned are the fraction of previous colorings that colored the 2 columns i and n-i+1. Since we had some choice in coloring previously, we keep track of that number, which is basically

$$$d_i = \sum_{k=1}^i (a_k - 2)$$$

If we have n columns and we colored k of them, then the ratio where we colored both i and n-i+1 is

$$$\frac{\binom{n-2}{k-2}}{\binom{n}{k}} = \frac{k(k-1)}{n(n-1)}$$$

Similarly for one specific column colored and the other not colored, it is

$$$\frac{\binom{n-2}{k-1}}{\binom{n}{k}} = \frac{k(n-k)}{n(n-1)}$$$

Now just plug n = n — 2*i and k = d_i, and you have the DP formula.

340207087

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Div.2B was that hard! But like all the problems ABCD :)

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +66 Проголосовать: не нравится

I hate 1E.

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

"A simple algorithm works, just make Alice take all items in S in increasing order, and when Alice wants to take some item but it is not the first remaining item according to her priority order, Bob takes items till it becomes first in her priority order."

Can anyone explain Div2E / Div1C editorial a bit easily, like how the above statement came ?

»
11 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится +141 Проголосовать: не нравится

Since editorials for D1F/G are not currently out, here are some somewhat handwavy outlines of my solutions:

F: WLOG, assume the graph is a tree (if it isn't, take a spanning tree and pretend the edges outside the spanning tree don't exist at the start). For the first query, take k = 3 and connect all pairs of vertices with distance 2. For the second query, take k = ceil(diam / 2) + 1, where diam is the diameter of the tree. We can construct paths with length ceil(diam / 2) between any two remaining vertices.

Indeed, by using the edges from the first query as needed, we can get from one vertex to another in any number of moves between ceil(dist(u, v) / 2) and diam and dist(u, v). If dist(u, v) < ceil(diam / 2), let d be the vertex on the diameter furthest from u. We can follow the path from u to v until it diverges from the path from u to d. Then, through a little casework, we can show that it's possible to visit every vertex between our current position and d and then return to the path to v. (If we don't need this many vertices, we can just not include d and the vertices closest to d on the path.) This lets us achieve any number of moves between dist(u, v) and the number of vertices in the union of the paths from u to d and u to v, which is at least dist(u, d). Thus, we can achieve any number of moves between ceil(dist(u, v) / 2) and dist(u, d). Since dist(u, v) <= diam and dist(u, d) >= ceil(diam / 2), this lets us achieve distance ceil(diam / 2), so we're done.

Here's my code. The complexity is O(n^3).

G: (very rough outline, I find this one fairly hard to explain...)

First, let's think about a subproblem that comes up throughout the task: how many sequences of a 0's and b 1's have longest nondecreasing subsequence (LIS) at least c? We can do complementary counting: for us to have no increasing subsequence of length c, at any point, the number of 0's used so far and the number of 1's remaining must be less than or equal to c. We can think about this as the number of grid paths from (0, 0) to (a, b) where at all points on the path, x + (b — y) < c. I think this subproblem is somewhat well-known in some circles (though it wasn't to me until I solved this task...). Assuming c >= max(a, b), this works out to (a + b) choose a — (a + b) choose c, so (a + b) choose c sequences have LIS at least c. (if c <= max(a, b), all (a + b) choose a sequences have LIS at least c.)

Now, let's get back to the main problem. To deal with the constraint that b is larger than a, iterate over the longest prefix shared between both strings. The next character of a must be 0, and the next character of b must be 1. This gives us O(n) (with n = x + y) possible prefixes of b, and we need to count the number of solutions with each prefix.

To reframe the LIS condition, we'll choose the minimum i such that B[0..i] has LIS k; then, we require that i exists (i.e. B itself must have LIS at least k) and that b[i+1..n] has LIS k. The easy case occurs when our prefix already has LIS at least k, so i has been predetermined. When this is the case, we can just ignore B[0..i], and we just need to ensure that the remainder of b has LIS at least k. This can be handled using the solution to the subproblem above.

The harder case is when our prefix has LIS less than k. In this case, let's iterate over i, i.e., we are iterating over the length of the shortest prefix with LIS k. (This is somewhat motivated by the solution to the subproblem, which largely depends on a+b.) For a fixed i, we can identify the minimum and maximum number of 0s in our prefix of length i, and for these two cases, we can directly compute the number of ways to choose our prefix (noting that we must subtract out cases where the prefix of length i-1 has LIS at least k) and multiply by the number of ways to choose our suffix with the remaining 0s and 1s.

Then, we can prove that the number of ways to choose our prefix is the same for all numbers of 0s strictly between the minimum and the maximum. The rough idea is that if we had more 0s than we needed to guarantee that our prefix has LIS k, the prefix of length i-1 would be guaranteed to have LIS k. Thus, we can have at most exactly the number of 0s needed to guarantee LIS k, which means any number of 0s less than the maximum won't guarantee LIS k. A similar argument applies to the 1s, meaning that if we have more than the minimum number of 0s, we aren't guaranteed to have LIS k. When we apply the subproblem solution, this ensures that we are in the (a + b) choose c case and not the (a + b) choose a case, and since a+b is constant, the whole expression is too.

From here, we can precompute the number of ways to choose a valid suffix with a 0's and b 1's with LIS at least k for all a and b, and using prefix sums, we can multiply the number of valid prefixes for each number of 0s times the number of valid suffixes over all possible numbers of 0s/1s for the suffix. Adding this to the minimum/maximum number of 0 case (which we compute separately as an edge case) gets us the answer for the given prefix of b, completing the solution. The complexity is O(n^2).

I doubt if my code will be helpful to read (though it does technically have a few comments...); if you'd like to take a look, it's at this link.

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Problem D is good

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I found problem B really challenging!

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can somebody explain me C.As i am unable to understand it from the editorial.

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
  • In the Div2-C, for the test case 3 with
  • N = 4
  • {6149048, 26582657, 36124499, 43993239, 813829899, 860114890, 910238130, 913669539} -
  • for K = 2, we have been given 1737022233, as the output
  • but since there can at most be two persons simultaneously
  • then how can this not be considered
  • 1st person enters at point 1 then will leave at 8, 2nd person gets in at 2 and exits at 7?
  • which will give 1791175964, which is greater than the one as the answer given???
»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

For 1C, I thought the condition should be $$$pox_x \lt pos_y$$$ where $$$pos_i$$$ is the position of item $$$i$$$ in array $$$b$$$, instead of $$$b_x$$$ < $$$b_y$$$

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I have a general question about div2 e. During the contest, I found O(n^2) dp solution is quite naive.

$$$dp[i][j] = max(dp[i][j], dp[i - 1][j] + v[a[i]])$$$
$$$dp[i][j] = max(dp[i][j], dp[i][j - 1])$$$

That is, we have a row transition from condition (if b's j selected a[i], add 0) and always true column transition.

Although row transition is easily implemented by lazy propagation, I cannot solve this problem as I failed to implement column transition in O(logn).

I thought at each level i, we can keep the segment tree monotonic increasing. But the editioral says it is enough to change only one element. How can they think this simple trick easily? Just one thing for optimization always bothers me. Could you give some tip to resolve this situation? Most of the time, I can't think some minor point. Thank you in advance!

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

In the solution of Limited Edition Shop, it seems that there are some ambiguous points.

  1. $$$b_i$$$ should be the position of $$$i$$$ in orginal $$$b$$$, but there's no explanation.
  2. And in the transitions, the first $$$b_i$$$ should be $$$b_{i+1}$$$.
»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

div2 D such an amazing problem. Once you find the key point by observation(the graph), you can immediately solve this problem

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I need a O(n*n) solution C++ code for div2 E, the Editotrial is not very clear to me QAQ......

»
11 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone explain the solution to E1 in more detail? I dont understand what the array waste stands for because waste contains the value which appear both in [tl, tr] and outside it. just implies waste contains all values xD

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I hope I add the conclution of Div1 C.

First, make $$$a_i=i$$$ is right.But how does the array b change?

Obviously, if the number $$$x$$$ becomes $$$y$$$, then find $$$i$$$ such that $$$b_i=x$$$, and change $$$b_i$$$ to $$$y$$$, which can be achieved by $$$O(n)$$$.

Next, Let $$$x$$$ choose, $$$y$$$ choose not(actually also $$$a_x$$$ and $$$a_y$$$).We will have two situations:

  • $$$x \lt y$$$ : We find $$$j$$$,$$$k$$$ such that $$$b_j=x$$$ and $$$b_k=y$$$.If $$$k \lt j$$$, we can know that this is impossible(If we want choose $$$y$$$, then we must choose array a until $$$k$$$. But $$$x$$$ is also chosen.). Similarly, we can know that $$$k \gt j$$$ is possible.

  • $$$x \gt y$$$ : We can choose $$$y$$$ first, so is possible both $$$k \lt j$$$ or $$$k \gt j$$$.

So, we can modify array b like this: If $$$b_j=x$$$, then let $$$Newb_x=j$$$.

Lastly, the array Newb is the array b mentioned in the solution ! We can copy the values from Newb to b.

This can explain why "For all $$$x\in S$$$, $$$y\in S$$$, if $$$x \lt y$$$, then $$$b_x \lt b_y$$$".

This is my code(Only the part of change array b):

    for(int i=1;i<=n;i++)M[a[i]]=i;
    for(int i=1;i<=n;i++)c[i]=M[b[i]];//change the b[i] first
    for(int i=1;i<=n;i++)b[i]=c[i];
    for(int i=1;i<=n;i++)c[b[i]]=i;//find b[j]=x and change Newb[x] to j
    for(int i=1;i<=n;i++)b[i]=c[i];//copy the values

I hope it can help someone!

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

For Div.1 F, if we fix a root, we only need to consider two cases:

  • $$$\operatorname{dist}(u,v) \ge k$$$ : This is exactly the same as in the official editorial.

  • $$$\operatorname{dist}(u,v) \lt k$$$ :

The path can be split into three parts: $$$u \to \text{lca}$$$, then an “up-and-back” segment starting from the lca, and finally $$$\text{lca} \to v$$$.

Suppose that when going upward from the lca we eventually reach some node $$$x$$$. Let the nodes on this path be $$$p_0=\text{lca},p_1,\dots,p_{\text{len}}=x$$$.

We can then take all vertices with even (odd) indices in order, followed by all vertices with odd (even) indices in reverse order.

It can be checked that at least one of these two traversals correctly handles the cases $$$u=\text{lca}$$$ or $$$v=\text{lca}$$$.

Finally, it can be proven that if we try both endpoints of the diameter as the root, then at least one choice will always work.

340368161

»
11 месяцев назад, скрыть # |
Rev. 4  
Проголосовать: нравится 0 Проголосовать: не нравится

TheScrasse , There seems to be some error in the editorial for Div2E , (Limited edition shop).

As per editorial, we assume, preference of items for Alice is $$$A_i = i$$$.

So, imagine array A (preference of Alice) = [1 , 2 , 3 , 4 , 5 , 6 , 7].

And.............. preference order for Bob B = [3 , 4 , 2 , 6, 1 , 7 , 5].


Now, imagine, I want to select a set S = { 1 , 4 , 6 } ( basically I want to select items 1 , 4 , and 6 ). S' = { 2 , 3 , 5 , 7 } ( items which are not selected by Alice, so must be selected by BOB).

Let's look at the condition given in the editorial...

For $$$x \notin S$$$, $$$y \in S$$$ , this condition must hold true $$$B_x \lt B_y$$$.

If we get all the pairs (x , y) where (x < y) and $$$x \in S'$$$ (or $$$x \notin S$$$ otherwise) and $$$y \in S$$$ , we have 5 pairs. (2 , 4) , (2 , 6) , (3 , 4) , (3 , 6) and (5 , 6).

for (2,4) , $$$B_2$$$ = 4 , $$$B_4$$$ = 6, So we can see $$$B_2$$$ < $$$B_4$$$.

for (2,6) , $$$B_2$$$ = 4 , $$$B_6$$$ = 7, So we can see $$$B_2$$$ < $$$B_6$$$.

for (3,4) , $$$B_3$$$ = 2 , $$$B_4$$$ = 6, So we can see $$$B_3$$$ < $$$B_4$$$.

for (3,6) , $$$B_3$$$ = 2 , $$$B_6$$$ = 7, So we can see $$$B_3$$$ < $$$B_6$$$.

for (5,6) , $$$B_3$$$ = 1 , $$$B_6$$$ = 7, So we can see $$$B_3$$$ < $$$B_6$$$.


Even after this condition, holds, we can never select the set of items { 1 , 4 , 6 } from order of preferences. Please help clarify this.

------------------------------------------------------------------ Update :

As per TheScrasse's reply, the editorial error has been fixed. this comment's content is outdated.

»
9 месяцев назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

In 2150D - Attraction Theory, I somewhat quickly arrived at counting the number of valid arrays of length $$$k$$$ as

$$$ c=[x^n] \left(\frac{x}{1-x}\right)^2 \left(\frac{x}{1-x^2}\right)^{k-2} = [x^{n-k}] \frac{1}{(1-x)^2} \frac{1}{(1-x^2)^{k-2}}, $$$

after which I spent embarrassingly much time on figuring out how to to reconcile things with $$$1-x$$$ and $$$1-x^2$$$ in the denominator. The intended solution ultimately does it by fixing the parity of the first and the last non-zero number, which I eventually also arrived to. After doing so, I also figured out that it is actually simple to count while still being in genfunc space:

$$$ c=[x^{n-k}] \frac{(1+x)^2}{(1+x)^2}\frac{1}{(1-x)^2} \frac{1}{(1-x^2)^{k-2}} = [x^{n-k}] \frac{(1+x)^2}{(1-x^2)^k}, $$$

which now has a uniform way to extract $$$x^{n-k}$$$, independently of the parity of border parts. Ultimately, it is still equivalent to what intended solution is doing, but I wanted to share the way to do in purely genfunc way. Then, the total sum over border elements can also be expressed as $$$s = [x^{n-k}] \frac{(1+x)^3}{(1-x^2)^{k+1}}$$$, and over inner elements as $$$\frac{c \cdot n-2s}{k-2}$$$.

»
8 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I think there's a mistake in div2C editorial, starting from "Now we have to calculate the following terms:", I don't understand the rationale behind the formula, why there're multipliers up to k, aren't multipliers of +-1 next to a_i enough? There isn't an explanation how terms S1, S2 and S3 are combined to calculate the final answer. Solution (code) makes sense though, but it uses different approach, deriving k from k-2.

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

2151C — Incremental Stay is a shit and uncleared answer

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Sorry for necroposting. I got Div1E1 from a TLE bot on discord. I think the bound of $$$4n + 2 \lceil \log_2 n \rceil$$$ queries is very loose in most cases and thought it can be reduced down to something around $$$3.7 \cdot n + c$$$ where $$$c$$$ is some constant (for small cases). Next is a semi-formal proof.

Denote by $$$f(d, w)$$$ the number of queries used to find the value, given that we have $$$w$$$ "waste" and $$$d$$$ elements that could be the "lonely value". We can show that $$$f(d, w) = \frac{5}{3} d + w + f(\frac{d}{3}, \frac{d}{3}+\frac{w}{2})$$$.

We do that by noting that for a random permutation for a number that appears twice (the chance of it being only in the first half) = (the chance of it being only in the second half) = (the chance of it being in both halves) = $$$\frac{1}{3}$$$. If we query some number with one half and we get $$$0$$$ then we don't need to query the other half. Thus we have $$$\frac{1}{3} \cdot 1 + \frac{1}{3} \cdot 2 + \frac{1}{3} \cdot 2 = \frac{5}{3}$$$.

Similar to the editorial we query each of the wastes once so $$$+w$$$. Note that on average we get half of the wastes on each half (again, if we consider a random permuation of the indices instead of an interval) so we have $$$\frac{w}{2}$$$ waste in the next step. We also have $$$\frac{1}{3} \cdot d = \frac{d}{3}$$$ expected waste in the next step (from the values that appear in both halves). In total $$$\frac{d}{3} + \frac{w}{2}$$$ waste in the next step.

If we unfold the definition a bit and ignore the terms containing $$$d$$$, we will see a pattern (consider $$$\text{_}$$$ as a placeholder for $$$\text{constant} \cdot d$$$).

$$$f(d, w)= \text{_} + w + f(\text{_}, \text{_} + \frac{w}{2}) = \text{_} + w + \frac{w}{2} + f(\text{_}, \text{_} + \frac{w}{4}) = \text{_} + w + \frac{w}{2} + \frac{w}{4} + f(\text{_}, \text{_} + \frac{w}{8}) = \dots = \text{_} + w \cdot \displaystyle{\sum_{k=0}^\infty \left( \frac{1}{2} \right) ^ k} = \text{_} + 2w$$$

This leads us to $$$f(d, w) \leq \frac{5d}{3} + 2w + f(\frac{d}{3}, \frac{d}{3}) \leq \frac{5d}{3} + 2w + \frac{2d}{3} + f(\frac{d}{3}, 0) = \frac{7d}{3} + 2w + f(\frac{d}{3}, 0)$$$.

Let now $$$g(n) = \frac{7n}{3} + g(\frac{n}{3})$$$. Note that $$$g(n) = f(n, 0)$$$. We now get that $$$g(n) \leq \frac{7n}{3} \cdot \displaystyle{ \sum_{k=0}^\infty \left( \frac{1}{3} \right)^k } = \frac{7n}{3} \cdot \frac{3}{2} = \frac{7}{2} n$$$. Thus $$$f(n, 0) \leq \frac{7}{2}n$$$.

This proof is not very formal, there are missing expected values and stuff. I also tested it locally with random tests and the maximum factor is around $$$3.7$$$ for large values of $$$n$$$. Sadly, for small values it fails quite badly, sometimes reaching and even slightly exceeding $$$4$$$ (although a constant like $$$40$$$ or something might fix this still)

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can anyone explain, in Div1B, for the first test case, why the following grid is not valid?

10001 10001 00100 00000 00000

here 1 represents black and 0 white.

this grid satisfies all the given conditions still they haven't considered it as a valid solution for test case 1

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

2151C — Incremental Stay Editorial: We maintain a prefix sum, a suffix sum etc. to calculate this expression.

Meanwhile dominator in code: Ooom bhat bhatt swaha!