J. Whistle's New Car time limit per test 15 seconds memory limit per test 512 megabytes input car.in output standard output Whistle has bought a new car, which has an infinite fuel tank capacity. He discovered an irregular country since it has n citi…
Discription Statements Whistle has bought a new car, which has an infinite fuel tank capacity. He discovered an irregular country since it has n cities and there are exactly n - 1roads between them, of course, all cities are connected. He is so much…
https://vjudge.net/problem/Gym-101147J 题意: 有n个城市,每个城市有一个权值,表示在这个城市的加油站可以加多少油. 现在要计算每个城市i,有多少个城市j可以到达它: ① j 是 i 的子树. ② 在城市 j 加满Xj的油后不再加油能到达 i 城市. 思路:我们从根结点出发,dfs整棵树,在dfs的过程中,我们维护一个道路长度的和sum[],sum[j]就是1到第j个城市的路径之和. 假如我们现在dfs到了第j个城市v,此时1~j的路径之和就是sum[j],…
题目描述 Farmer John has installed a new system of pipes to transport milk between the stalls in his barn (), conveniently numbered . Each pipe connects a pair of stalls, and all stalls are connected to each-other via paths of pipes. FJ is pumping milk…