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

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

Statement: You've given a tree of N (1<=N<=1e5) nodes with the root at 1. Each node is initially healthy except the root node. You're given q (1<=q<=1e5) queries and each query is of 2 types. For each query of type 2, store the answers and return the final answer vector.

Type 1: You're given node v, make it unhealthy. Type 2: You're given node v, find the nearest unhealthy node from v. Distance is calculated as the number of edges between the current node v and the nearest unhealthy node.

Please share your optimized logic.

TIA

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

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