Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

Автор ArvinCiu, история, 23 часа назад, По-английски

A. Meaning Mean

Author: athin
Developer: ArvinCiu
Editorial: Kinon

Tutorial

B. Maximize Mex

Author: joelgun14
Developer: joelgun14, CyberSleeper
Editorial: Pyqe

Tutorial

C. Adjust The Presentation

Author: ArvinCiu
Developer: icebear30, gansixeneh
Editorial: ArvinCiu, gansixeneh

Tutorial

D. Boss, Thirsty

Author: ArvinCiu
Developer: CyberSleeper
Editorial: Pyqe

Tutorial

E. Digital Village

Author: CyberSleeper
Developer: ArvinCiu

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

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

Brute force in $$$\mathcal{O}(nm^2)$$$ can pass problem D.

Submission

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

    Hacked :)

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

Segment tree for C2 seems like a bit of overkill. You can keep vector of sets of indices in b for each element of a. (including m+i, or just any large const, if you allow non-strict increasing arrays instead). Then, for each update you just need to check whether the increase condition still holds for the adjacent pairs and update the counter. If the counter is full, yield YA.

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

FINALLY.

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

My solution to E3:

Call a node "special" if it is one of the $$$p$$$ given nodes. Call a node "chosen" if it is one of the $$$k$$$ nodes in the chosen subset.

Build the Kruskal Reconstruction Tree (KRT) of the graph, with $$$2n - 1$$$ nodes. All nodes in the original graph are given the same label in the KRT.

For some special node $$$x$$$, let $$$y$$$ be the lowest ancestor of $$$x$$$ in the KRT with at least one chosen node in the subtree of $$$y$$$. The maximum edge weight needed to get to a chosen node from special node $$$x$$$ in the original graph, is the weight of the edge that corresponds to $$$y$$$ in the KRT.

I then transformed this problem a bit. Let $$$f(i)$$$ be the edge weight that corresponds to node $$$i$$$ in the KRT (if $$$i \leq n$$$, then $$$f(i) = 0$$$). Let $$$g(i)$$$ be the number of special leaves in the subtree of $$$i$$$ in the KRT. Let the the value of a node $$$i$$$ be $$$g(i) * (f(i) - f(par[i]))$$$. Choose $$$k$$$ leaves in the KRT, to minimize the sum of values of nodes which have at least one chosen leaf in its subtree.

This works, because the contribution of some special node $$$x$$$ will be $$$(f(y) - f(par[y])) + (f(par[y]) - f(par[par[y]])) + \dots = f(y)$$$, where $$$y$$$ is the lowest ancestor of $$$x$$$ with a special node in its subtree.

Greedy solution
DP solution
»
3 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

After this round my rating increased to 1399, and i am very grateful to the rating system.

»
99 минут назад, # |
Rev. 2   Проголосовать: нравится +4 Проголосовать: не нравится

E is very nice. Learn a new trick about how to use minimum spanning tree in this.
Btw, editorial E only E3 ?!