当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6844:Animism

题目描述
Notice:Don't output extra spaces at the end of one line.

Koishi loves Subterranean Animism(SA).

The map of SA is a undirected tree with $n$ nodes and $n-1$ roads.

Koishi loves wander around SA by Rin's corpse cart. The cart use nuclear power. It take $1$ point power to pass one road. Koishi has $q$ wandering plan, in the $i$-th plan Koishi wants to wander from $x_i$ to $y_i$, and the cart has $p_i$ points of power initially.

Obviously, in some plans, Koishi can't arrive the destination. To avoid this, Koishi asks Utsuho to set some nuclear-power filling station. There are $m$ such stations. The $i$-th of them is located in the node $c_i$ and the level of this station is $d_i$. When Koishi arrive node $c_i$, she can add $(d_i-s)$ points of power to her cart or do nothing. Here $s$ represents the amount of power the cart has currently.

For each plan, Koishi wants to know whether this plan can be finished successfully. Notice that she can pass the same road many times.
输入解释
The first line contains of a positive integer $T(1\leq T\leq 500)$, representing $T$ test cases.

in each test case, the first line contains three positive integers $n,m,q(1\leq n,m,q\leq 10^5)$,representing the number of nodes, power stations and plans.

Each of the following $n-1$ lines contains two positive integers $u_i,v_i$, representing a road between $u_i$ and $v_i$. It guarantees the input map is a tree.

Each of the following $q$ lines contains three positive integers $x_i,y_i,p_i(1\leq x_i,y_i\leq n,1\leq p_i\leq 10^9)$. It describes the $i$-th plan.

Each of the following $m$ lines contains two positive integers $c_i,d_i(1\leq c_i\leq n,1\leq d_i\leq 10^9)$. It describes the $i$-th power-stations.

There are at most $500$ test cases and at most $12$ test cases with $n+m+q>5000$
输出解释
For each test case, output $q$ lines.

in the $i$-th line, if the $i-$th plan can be finished, output "YES", otherwise, output "NO"
输入样例
2
10 3 10
2 1
3 1
4 2
5 1
6 2
7 1
8 2
9 5
10 6
7 2 3
2 6 1
8 8 3
8 6 3
10 3 1
7 9 2
9 5 3
2 2 2
9 8 2
7 10 3
9 1
7 2
8 1
10 3 10
2 1
3 1
4 3
5 4
6 3
7 3
8 6
9 8
10 6
7 9 1
6 8 2
6 9 2
4 3 1
6 9 2
5 2 1
8 2 3
1 5 2
9 5 2
7 10 2
9 1
6 1
2 1
输出样例
YES
YES
YES
YES
NO
NO
YES
YES
NO
NO
NO
YES
YES
YES
YES
NO
NO
NO
NO
YES
来自杭电HDUOJ的附加信息
Recommend IceyWang

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6844

最后修改于 2020-10-25T23:34:52+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
40000/15000MS(Java/Others) 524288/524288K(Java/Others)