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

Автор spam_123, история, 5 лет назад, По-английски

Hey , Can anyone please tell how to solve D of today's atcoder beginner contest

Link here

How to efficently brute it ?

Any help will be appreciated

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

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

Hey! I'm one of the writer in ABC 123, and I'll explain solution for D.
There are four solutions.

First Solution O(K^2 log K)
Second Solution O(K log^3 K)
Third Solution O(K log K)
Fourth Solution O(K log max)

By the way, you can use this blog as discussion of ABC 123 (because we didn't write announcement because of clashing to codeforces round).

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

    Hello, I think the editorial PDF for the fourth solution of D puts a wrong link of source code.

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

    I wrote the 3rd solution in practice, but was not sure about its complexity. Can't the priority queue hold elements more than $$$K$$$ in intermediate stages, so that its complexity is larger than $$$O(Klog K)$$$?

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

      Yes. More than $$$K$$$, but less than or equal to $$$3 \times K + 1$$$, so it's $$$O(K)$$$.
      That's because, if it has $$$A_i + B_j + C_k$$$ in top-$$$K$$$, priority queue holds $$$3$$$ elements $$$A_{i+1} + B_j + C_k, A_i + B_{j+1} + C_k, A_i + B_j + C_{k+1}$$$. That doesn't appear in three will not be held in priority queue. This implies that the maximum pushed elements in priority queue is at most $$$3 \times K + 1$$$ (including $$$A_1 + B_1 + C_1$$$).

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

        Can you Please explain why you add + 4 to the formula of problem C .

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

          It's easy, that's because the traveling distance from start to goal, without the designated selected road, is $$$4$$$.