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

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

Contest hosted on DMOJ https://dmoj.ca/contest/dcc1

P1 — The Cathedral of Learning

Спойлер

P2 — Square Sum

Спойлер

P3 — Soccer Court

Спойлер

P4 — Increasing Sequence With Gap

Спойлер

P5 — Get It Twisted, They Will Divide Us [subtask 1 only]

Спойлер
  • Проголосовать: нравится
  • +17
  • Проголосовать: не нравится

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

Another way to think about P4 is to observe that there exists an longest subsequence that includes all the -1s. So then we can do a DP over the non -1 values, where we can transition from j to i if there's enough of a gap to fit all of the -1 values between j and i. After rewriting the inequality, the transition can be done with a BIT or segment tree.

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

    It can also be thought of as creating a new sequence $$$a^{(G)}$$$, where:

    • All elements $$$a_i = -1$$$ have been removed.
    • Let $$$c_i$$$ be the number of positions $$$j \lt i, a_j = -1$$$. Then $$$a^{(G)}_{i - c_i} := a_i - c_i \cdot G$$$.
    • The length requirement $$$K$$$ will be reduced by the number of $$$a_i = -1$$$.

    ... then solving it as if there are no $$$a_i = -1$$$.