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

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

March Cook-Off starts in less than 3h.

Setters are kefaa and chemthan.

Let's discuss the problems after the contest.

UPD. Contest is over. Congrats to the winners!

 uwi

 LHiC

 dreamoon_love_AA

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

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

I think I've seen the matrix restoration and array restoration problem somewhere before.

»
6 лет назад, # |
  Проголосовать: нравится +2 Проголосовать: не нравится

How to solve Chef Restores an Array?

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

    Two adjacent numbers are either related by a +/-1 or not related at all. If they are related by both, ans is 0. To find the relations in linear time, we can use 2 prefix DPs, one for 'I' relations and the other for 'D' relations.

    From numbers you already know, you can traverse using known relations(edges) to get unknown numbers and at same time verify other known numbers. We need to make sure that these numbers are in the range [1, k]. For numbers that are still unknown, they will form a forest of chains. In each of these chains, we need to see the difference between the largest and smallest.

»
6 лет назад, # |
  Проголосовать: нравится +23 Проголосовать: не нравится

Editorials please

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

    chemthan(or anybody else) can you explain the approach for the maximum path on tree question???

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

      Firstly we ignore gcd(u, v), just find the maximum of dist(u, vmin(u, v). Iterating vertices in decreasing order by values written on them and maintain DSU structure. Each time we connect an edge (u, v), we're only interested in paths pass through that edge. We will maintain diameter of each component. If (x, y) is diameter of u's component, (z, t) is diameter of v's component then the longest path passes through (u, v) is among (x, z), (x, t), (y, z), (y, t). Complexity is O(LCA(N) + DSU(N)).

      Now, finding the maximum of dist(u, vmin(u, vgcd(u, v): For each d, we consider only vertices that values written on them are multiplier of d and apply above approche for each group. The sum of all groups is at most N * max_number_of_divisor_of(a[i]) ~ 6e6. We can optimize LCA part by using LCA O(1) per query, so total complexity will be O(DSU(N * max_number_of_divisor_of(a[i])).

»
6 лет назад, # |
  Проголосовать: нравится +10 Проголосовать: не нравится

how do you solve |S|*AND(S) problem

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

    fix the AND, iterate over supermasks, find largest connected component with dsu.

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

      there are ~2^20 possible values for the AND right? How would you use DSU to find the largest connected component for each value of AND?

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

        say we want to make the and equal to x, add the vertices that are supermasks of x one by one. After adding one we check if its parent is also supermask of x, if that is the case we merge them with dsu. Complexity: 3^17