HBC24048交叉乘[USACO 2017 Jan P]Promotion Counting题解 (thecowshaveonceagain)

庄子墨 算法基础篇 29 0
全网最全C++题库,助您快速提升编程技能!题库丰富多样,涵盖各个领域,让您在练习中不断成长!
The cows have once again tried to form a startup company, failing to remember from past experience that cows make terrible managers!

The cows have once again tried to form a startup company, failing to remember from past experience that cows make terrible managers! The cows, conveniently numbered 1…N (1≤N≤100,0001leq Nleq 100,0001≤N≤100,000), organize the company as a tree, with cow 1 as the president (the root of the tree). Each cow except the president has a single manager (its "parent" in the tree). Each cow i has a distinct proficiency rating, p(i), which describes how good she is at her job. If cow i is an ancestor (e.g., a manager of a manager of a manager) of cow j, then we say j is a subordinate of i. Unfortunately, the cows find that it is often the case that a manager has less proficiency than several of her subordinates, in which case the manager should consider promoting some of her subordinates. Your task is to help the cows figure out when this is happening. For each cow i in the company, please count the number of subordinates j where p(j)>p(i).

HBC24048交叉乘[USACO 2017 Jan P]Promotion Counting题解
(thecowshaveonceagain)-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
不断学习,不断挑战,才能在编程领域中脱颖而出!全网最全C++题库,助您成为编程高手!

标签: HBC24048交叉乘[USACO 2017 Jan P]Promotion Counting题解