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

建议使用的浏览器:

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

6612:Sindar's Art Exhibition

题目描述
Sindar is an excellent artist and she has many works. One day she decides to hold an exhibition tour in her country. Her country is a tree, the nodes of which are the cities and the edges between the nodes are the roads between cities.
The value of an exhibition are determined by the number of works on the exhibition and the citizens' favorability of art. Generally speaking, if there are $m$ works in the exhibition, and the citizens' favorability is $k$, then the value of the exhibition will be $m*k$.
Her tour will begin at city $s$ and end in city $t$. She will begin the tour with $x$ works, but after she holds the exhibition in every city, she will choose $y_i$ suitable works and donate them to the local orphanage, which means that there will be only $x-y_i$ works when she holds the next exhibition, and $x-y_i-y_j$ works in the exhibition after the next, supposing that she will pass city $j$ after city $i$.
Now she has many tours and she want to know every tour's value mod $10^9+7$. And sometimes she may change one city's favorability.
输入解释
There are multiple test cases. The first line of the input contains an integer $T$, indicating the number of test cases. For each test case:
The second line contains one interger $n$, indicating the number od cities. $(1\leq n \leq 10^5)$
It's guaranteed that $\Sigma n\leq 3*10^5$
The next line contains $n$ interger $f_i$, the $i-th$ interger indicates the citizens' favorability of art in city $i$.($0\leq f_i\leq 2*10^9)$
The next line contains $n$ interger $y_i$, the $i-th$ interger indicates the number of works Sindar will donate to the orphanage in city $i$.$(0\leq y_i\leq 10^4)$
Each of the following $n-1$ lines contains two intergers $u,v$ indicating that there is a road between city $u$ and city $v$. ($1\leq u,v \leq n$)
The next line contains two interger $q$,indicating the number of tours and the number of works Sindar will donate to the local orphanage.$(1\leq q \leq 10^5)$
Each of the next $q$ lines contains one instruction. And there are two kinds of instructions:
$1\ s\ t\ x$ indicates the start city ,the end city and the number of works Sindar owns at first. $(1\leq s,t\leq n , s\neq t,x\leq 2*10^9)$
$2\ c\ v$ indicates Sindar wants to change the favorability of city $c$ to $v$.$(1\leq c\leq n,0\leq v\leq 2*10^9)$
It is guaranteed that $x \geq dis(s,t)*y$. $dis(s,t)$ indicates the number of cities you must pass from $s$ to $t$.
输出解释
For each query, output one interger indicates the tour's value mod $10^9+7$
输入样例
1
6
1 2 1 4 5 6
1 1 1 2 2 2
1 2
2 4
2 5
5 6
1 3
2
2 3 3
1 6 3 10
输出样例
129

提示
129=6*10+5*8+2*6+1*5+3*4
来自杭电HDUOJ的附加信息
Recommend chendu

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

源链接: HDU-6612

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

共提交 0

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