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

建议使用的浏览器:

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

6353:Daylight

题目描述
Noah owns an unrooted tree with $n$ vertices which are numbered from $1$ to $n$. Every morning Noah would like to pick two vertices $u$ and $v$ to get influence from daylight and then the influence spreads through edges, but the influence will be disappeared if it has passed through more than $w$ edges.
Your task is to calculate the number of vertices influenced by the daylight for each day. In addition, input data will be encrypted to make sure your solution is online.
输入解释
The first line contains one integer $T$, indicating the number of test cases.
The following lines describe all the test cases. For each test case:
The first line contains two integers $n$ and $m$.
Each of the following $(n - 1)$ lines contains two integers $u$ and $v$, indicating an edge between vertex $u$ and vertex $v$.
Let $\mathrm{lastans}$ be the last answer before each day. At the beginning day of each test case, $\mathrm{lastans}$ is initialized as $0$.
Each of the following $m$ lines contains three integers $u'$, $v'$ and $w'$, satifying $u = ((u' + \mathrm{lastans}) \bmod n) + 1$, $v = ((v' + \mathrm{lastans}) \bmod n) + 1$, $w = (w' + \mathrm{lastans}) \bmod n$, which means one day Noah will pick vertices $u$ and $v$ to get influence and the influence will be disappeared if it has passed through more than $w$ edges.
$1 \leq T \leq 100$, $1 \leq n, m \leq 10^5$, $1 \leq u, v, u', v' \leq n$, $0 \leq w' < n$.
It is guaranteed that no more than $10$ test cases do not satisfy $n, m \leq 10^3$ and the size of the standard input file does not exceed $32$ MiB.
输出解释
For each day, print the answer in one line.
It is guaranteed that the size of the standard output file does not exceed $7$ MiB.
输入样例
1
5 5
1 2
2 3
2 4
3 5
5 1 0
3 4 4
1 2 3
5 1 3
5 1 4
输出样例
2
4
5
5
5

提示
The decrypted information is the following:
Day 1: u = 1, v = 2, w = 0;
Day 2: u = 1, v = 2, w = 1;
Day 3: u = 1, v = 2, w = 2;
Day 4: u = 1, v = 2, w = 3;
Day 5: u = 1, v = 2, w = 4.
来自杭电HDUOJ的附加信息
Recommend chendu

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

源链接: HDU-6353

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

共提交 0

通过率 --%
时间上限 内存上限
20000/13000MS(Java/Others) 262144/262144K(Java/Others)