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

Автор omsincoconut, 3 дня назад, По-английски

I hope everyone enjoyed the tasks, and thank you for participating.

Thank you to the coordinators and testers for suggesting solutions and modifications to the tasks, as I alone wouldn't be able to solve my own tasks or make it to how it is right now. Also thank you to them for dealing with me since July.

Please tell me in the comments if the editorial is written incorrectly or unintelligibly somewhere. I'm not the best at phrasing some things, and would appreciate amendments to the editorial.

2078A - Final Verdict

Hint
Solution

2078B - Vicious Labyrinth

Hint 1
Hint 2
Solution
Extra

2077A - Breach of Faith

Hint 1
Hint 2
Solution
Note

2078D - Scammy Game Ad

Hint 1
Hint 2
Hint 3
Solution 1
Solution 2
Note

2077B - Finding OR Sum

Hint 1
Hint 2
Solution

2077C - Binary Subsequence Value Sum

Hint 1
Hint 2
Hint 3
Solution

2077D - Maximum Polygon

Hint 1
Hint 2
Solution

2077E - Another Folding Strip

Hint 1
Hint 2
Solution

2077F - AND x OR

Hint 1
Hint 2
Solution

2077G - RGB Walking

Hint 1
Hint 2
Hint 3
Solution

Some ending notes

Rating predictions
A small (?) story of this contest.
About Arcaea and the soundtracks
Разбор задач Codeforces Round 1008 (Div. 1)
Разбор задач Codeforces Round 1008 (Div. 2)
  • Проголосовать: нравится
  • +71
  • Проголосовать: не нравится

»
18 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

For 1A/2C how does the given solution ensure that the missing number produced satisfies the given constraint of being less than 10^18? Wasn't that also a constraint for the missing number? Am I missing something obvious here?

  • »
    »
    18 часов назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    We see that the right hand side of the equation in the editorial is the sum of $$$n+1$$$ terms which are no greater than $$$1e9$$$, so this can't be larger than somewhere around $$$2e14$$$.

    • »
      »
      »
      18 часов назад, # ^ |
      Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

      Ahh right. I forgot to see the bounds for b_i and just assumed they were from 1 to 1e18. Thank you for the clarification!

  • »
    »
    18 часов назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    Yes, just see that the input value for array b doesn't exceed 1e9, and all the elements in b would be less that 1e9, so with some basic calculations it will give you that the missing value wouldn't exceed around 1e14.

»
17 часов назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

can someone tell me why this div2 D solution doesnt work https://codeforces.net/contest/2078/submission/310325385 , its close but i dont know what is wrong with it

maybe i misread the problem at some point

thank you .

»
16 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

can someone please help me understand div2D DP editorial I just do not get it how is it working ?

  • »
    »
    15 часов назад, # ^ |
    Rev. 4   Проголосовать: нравится +1 Проголосовать: не нравится

    The key idea is that you must decide where to assign your bonus people based not just on the very next gate, but on all the gates that come later. At first, it might seem that looking just one step ahead would work, but that only gets you close—not the full answer as you can see here https://codeforces.net/contest/2078/submission/310322360.

    Instead, you need to see the entire future. By processing the multiplication operations from the end (backward), you determine the best multiplier chain available for each lane. In simple terms:

    When you add bonus people at a gate, every multiplication that comes after will boost that bonus.
    By working backward, you figure out the maximum boost (or “suffix multiplier”) each lane can get.
    This future boost tells you how valuable it is to add bonus people at a specific moment, so you can make the best decision right then.

    In short, knowing the full future multiplier effect lets you reliably choose the best lane to assign your bonus people—because once they’re placed, you can’t move them later

    you can check my code here https://codeforces.net/contest/2078/submission/310327912

    where i just compute the greatest multiplying factor using a prefix sum-like approach

    so that i can greedily and reliably decide which lane to insert the bonus people and by having that you can do a normal dynamic programming approach

    i would also encourage you to try all the ideas in your head and see them fail so that you can clear the doubts and understand it perfectly

    Hope this helped :)

»
15 часов назад, # |
Rev. 2   Проголосовать: нравится +16 Проголосовать: не нравится

In problem 1E, I don't think we can prove both $$$l,r$$$ should be in $$$s$$$.

We can only prove $$$l \in s$$$ and the last element $$$k \in s$$$ in $$$[l,r]$$$ has the same parity as $$$r$$$. For example, consider $$$a = [1,0,1]$$$, then $$$s = [1]$$$ but $$$l=1,r=3$$$. Of course in this case the following proof still holds so it doesn't matter much :)

  • »
    »
    5 часов назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    We can only prove $$$l \in s$$$ and the last element $$$k \in s$$$ in $$$[l, r]$$$ has the same parity as $$$r$$$.

    Yes, I had even mentioned it in the editorial but mistakenly wrote that $$$r$$$ should be present in $$$s$$$ as well. I have fixed it.

»
9 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

div2 D, DP solution. So hard to understand. Can't even understand the first sentence

»
5 часов назад, # |
  Проголосовать: нравится +7 Проголосовать: не нравится

In case someone struggles to understand the $$$\binom{n}{i+cnt_0}$$$ thing like me, we can think it this way.

For a sequence A selected by $$$\binom{n}{i+cnt0}$$$, we form our sequence B by taking the 1s in A and the 0s not in A. Say A has $$$x$$$ 0s. So we have $$$(i + cnt_0 - x)$$$ 1s and $$$(cnt_0 - x)$$$ 0s in B. The score would be $$$(i + cnt_0 - x) - (cnt_0 - x) = i$$$. Namely what we'd like to achieve.

  • »
    »
    4 часа назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Ohhhh, how is someone supposed to come up with something like this in contest tho?? Thank you so much, I've been trying to get deepseek to explain that derivation to me for the last half hour :_)

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

I solved Div2 D like "mathematically on paper", storing "variables" at each step and, in the end, maximizing a certain function based on the upper bounds of those variables.

Let's say that in the i-th step, the total number of added people is x. In the next step, I assign y to the left gate and x — y to the right gate, ensuring that 0 <= y <= x. This process continues until the last step, where I sum up the values in the left and right gates and maximize the function.

To achieve that maximization, I looped through the coefficients from the last to the first, setting the variable to 0 if the coefficient was ≤ 0 or to its upper bound if it was ≥ 0

»
111 минут назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Div2 D solution : "With the current number people of l+y on the left side and r+x−y on the right side, we can see that maximizing y is the optimal choice, because there always exist an allocation such that both number of people on the left and right side will exceed those with lower selection of y."

When y gets bigger, r+x-y gets smaller. I cannot understand why poeple on right side can be bigger when y is bigger.

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

    The more people you gained when entering the multiply gate can be placed on the right side to compensate, and you can do it so that the right side ended up big anyways.

»
107 минут назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I couldn't solve Div2 D during the contest because of the following simplification that I only realized upon reading the editorial.

Let's create an array for each lane: results[i] that states the total number of people we'd have at the end if 1 person entered at the ith gate. Then, if we have N people entering the ith gate then the total count would simply be N * results[i]. However, this only works in case of multiplication but not addition.

Let's try to understand the addition result better. It doesn't matter if X people enter or X+1, if the gate is of type +Y, then we'd get exactly Y extra people. Also, there is one person in each lane at the beginning and they cannot move to another lane (only additional ones can). Therefore, each of the addition operations in both lanes will be triggered no matter what choices we make.

Thus, we can compute an array where suffix_prod[i] denotes the total number of people at the end if exactly one person enters gate i. We can compute which of the next two lanes have a better multiplier (by processing the gates in reverse order) and the additional people can go through that lane, while the one person we had at start continues down the same lane. Then, we can process all the addition events in another loop and each of the additional people generated through them can go through the lane with better multiplier as discussed above.

O(N) implementation

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

    so is my understanding correct that

    • suffix_prod is similar to what results was doing but we can't use it to compute the final result
    • but we can use it to simulate the process and at every gate make a greedy choice for newly generated people and people who entered the gate continue on the same path?
»
79 минут назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

div2-D greedy editorial says When we get more people, place all to where the + will occur first.

is it supposed to be + (plus ) or it should be x ( multiply ) ?