Spheniscine's blog

By Spheniscine, history, 15 months ago, In English

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

P1 — The Cathedral of Learning

Spoiler

P2 — Square Sum

Spoiler

P3 — Soccer Court

Spoiler

P4 — Increasing Sequence With Gap

Spoiler

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

Spoiler
  • Vote: I like it
  • +17
  • Vote: I do not like it

»
14 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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.

  • »
    »
    14 months ago, hide # ^ |
    Rev. 3  
    Vote: I like it 0 Vote: I do not like it

    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$$$.