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

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

We will hold estie Programming Contest 2023 (AtCoder Regular Contest 169).

The point values will be 400-500-600-700-900-900.

We are looking forward to your participation!

  • Проголосовать: нравится
  • +132
  • Проголосовать: не нравится

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

How to solve A? 🤡

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

I haven't solve anything. I don't understand it's not my day, or the contest was quite difficult ?

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

How to solve B!?

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

Trying to solve C == Communicating with aliens

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

    Actually for me, it felt quite different (not necessarily easy, but still in a good way) compared to C's in previous ARCs. If you can come up with a trivial $$$\mathcal{O}(N^3)$$$, the rest should be simply optimizing it to $$$\mathcal{O}(N^2)$$$.

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

      But I thought $$$\mathcal O(n^2)$$$ is completely different from $$$\mathcal O(n^3)$$$ solution.

      My method is:$$$g[i][j]=$$$ ways to determine $$$a_1\cdots a_i$$$ and $$$a_i\neq j$$$.

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

        My method was, $$$dp[i][j]$$$ is number of prefix up to current element where $$$i$$$ comes last, repeated $$$j$$$ times. (transition is done inplace) This trivially leads to a $$$\mathcal{O}(N^3)$$$ DP. However, in here the greatest bottleneck in DP is simply shifting the DP table by one position which takes $$$\mathcal{O}(N^2)$$$ alone in the $$$a_i=-1$$$ case. So I used deques for the DP table, making it $$$\mathcal{O}(1)$$$ per row for shifting. Clearing a row is also tricky but it can be done in amortized $$$\mathcal{O}(1)$$$ using rollback ideas. This led to an $$$\mathcal{O}(N^2)$$$ solution for me.

        Implementation link

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

        My dp method is same as yours, but I solve it with inclusion-exclusion method in $$$O(n^2)$$$. submission

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

felt like B < C < A

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

For problem C, I use dp[i][j] to denote the number of ways, under the condition that, all the -1 in the first i positions have benn determined, and the last element is j.

dp[i][j] = sum of dp[i-x][y], where x=1,2,..,min(j, f(i,j)), and y=1,2,...,j-1,j+1,...,n, and function f(i,j) denotes the maximum number of j that we can have in a row from the i-th position to the left.

Note that for some fixed x, sum of dp[i-x][y] for y=1,2,..,j-1,j+1,..,n, can be computed by dpt[i-x]-dp[i-x][y], where dpt[i-x]=dp[i-x][1]+dp[i-x][2]+...+dp[i-x][n]. Next, sum of dpt[i-x]-dp[i-x][y] for x=1,2,..,min(j, f(i,j)), can be computed by prefix technique again.

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

can somebody explain to me why we need to find the depth? if the value gets replaced so A[P[i]] becomes A[P[i]] + A[i] the index still doesnt change as in P[i] doesnt become something else, only A changes, in other words only the same couple of numbers actually change A[1], can somebody tell me where did i go wrong? Problem A btw

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

does someone have a simpler solution for D?