题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1516 Your old uncle Tom inherited a piece of land from his great-great-uncle. Originally, the property had been in the shape of a
C. Uncle Bogdan and Country Happiness 1.分析: 本题可以用树上dfs预处理数据,再check的方式求解。 限制条件: 1.每个点的坏人数量是整数。 2.每个点的坏人数量大于子节点的坏人数量和+居民。(否则无法合理更新子节点) 3.每个点坏人的数量是正数。 2.算法描述 先树上dfs预处理出每个点会经过多少人,再判断(预处理)出每个点会经过多少坏人,最