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

建议使用的浏览器:

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

5566:Clarke and room

题目描述
Clarke is a patient with multiple personality disorder. One day, Clarke split into $n$ guys, the $i$th Clarke named $name_i$.
They live in $n$ rooms connected by $n-1$ roads. There is only one path between any two rooms. Now, their landlord is to check the name with a long list. The landlord will check $m$ times, at $i$th time, he wants to know the maximum length of the names which appear on the list $s_i$ on the path between $x_i$ and $y_i$ rooms(including $x_i$ and $y_i$).
输入解释
The first line contains an integer $T(1 \le T \le 10)$, the number of test cases.
For each test case:
The first line contains an integer $n(1 \le n \le 100000)$.
Then $n$ lines follow, the $i$th line contains a string $name_i$.
Then $n-1$ lines follow, the $i$th line contains an integer $f_{i+1}(1 \le f_{i+1} \le i)$, denoting there is an edge between $i+1$ and $f_{i+1}$.
Then $m$ lines follow, the $i$th line contains two integers $x_i, y_i(1 \le x_i, y_i \le n)$ and a string $s_i$.
Every string is composed by lower letter.
$1 \le |name_i|, |s_i|, \sum_{i=1}^{n} |name_i|, \sum_{i=1}^{m} |s_i| \le 100000$
输出解释
For each test case, print $m$ lines with the answers.
输入样例
1
4
a
ab
abc
d
1
2
1
3
1 1 abc
1 1 d
1 3 abc
输出样例
1
0
3

Hint:
Ask 1: $a$ appears in $abc$, so the answer is $1$.  
Ask 2: There is no one appears in $d$, so the answer is $0$.  
Ask 3: $a$, $ab$ and $abc$ appear in $abc$, so the answer is $3$.  
来自杭电HDUOJ的附加信息
Recommend hujie

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

源链接: HDU-5566

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

共提交 0

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