Advertisement
A_Tammaa

Untitled

Mar 29th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. ---- Military Problem ----
  2. There are n officers in Berland Army.
  3. It's an undirected Map.
  4. A special case that the commander has no sub commander.
  5. - Construction of the army-
  6. A tree consisting of n vertices, in which vertex u corresponds to officer u.
  7. (ui,ki) where ui us some officer, and ki is a positive integer.
  8. To process, the i-th query imagine how a command from ui
  9. spreads to the subordinates of ui.
  10. Typical DFS (depth-first search) algorithm is used here.
  11. INPUT
  12. FIRST LINE:
  13. n-1 integers p2,p3,…,pn (1≤pi<i),
  14. where pi is the index of the direct superior of the officer having the index i.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement