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

建议使用的浏览器:

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

5678:ztr loves trees

题目描述
Super Deity ztr likes trees from childhood,CCTV-children:"The apple on the apple tree.You and I under the apple tree.Play games in front of the apple tree.So many happiness".

One day,qzh visit ztr to ask some questions.To give a tree with a root,each vertex has a value.Each time query the median of a subtree.

ztr said:this is a water problem,do you do it?But qzh show cannot help but want you who is also a Super Deity to help him.Could you help him?
输入解释
There are T test cases. The first line of input contains an positive integer T indicating the number of test cases.

For each test case:

Each line contains two positive integer n,m.indicating the number of vetrex and the number of query times.
The next line contains n numbers, the ith number indicating the value of vertex i.
The next n-1 lines,each line contains two numbers u and v,indicating there is a edge form u to v.

The next m lines, each line contains a numbers x.indicating query the median of subtree x.

$1<=T<=3,1<=n<=10^{5},1<=m<=10^{6},1<=u<=v<=n,1<=val<=10^{9}.$
The vetrex 1 is the root of the tree.Guarantee input a tree with a root.
输出解释
For each test case:print a line.To avoid huge output,you should hash each answer first,then print it.

The method to hash:a[i] indicates the ith query result,$ans =\sum a[i]*10^{m-i} \;mod\;1,000,000,007$ Round to the nearest tenth
输入样例
1
5 3
1 2 3 4 5
1 2
2 3
3 4
4 5
1
2
3
输出样例
339.0
来自杭电HDUOJ的附加信息
Recommend wange2014

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

源链接: HDU-5678

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

共提交 0

通过率 --%
时间上限 内存上限
6000/2500MS(Java/Others) 131072/65536K(Java/Others)