spam_123's blog

By spam_123, history, 5 years ago, In English

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

  • Vote: I like it
  • +11
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
Rev. 5   Vote: I like it +17 Vote: I do not like it

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 years ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

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

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

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

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

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