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

how to solve this problem

Правка en1, от jyangli, 2024-10-13 00:54:08

You have directed acyclic forest. Every node except root nodes have 1 parent.

Query 1: Change parent of one node or make it a root node(it is guaranteed graph will not have cycle)

Query 2: input a node and output the root of the tree that node is in.

Number of nodes = 2e5 Number of queries = 2e5

Теги tree

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский jyangli 2024-10-13 00:54:08 331 Initial revision (published)