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

建议使用的浏览器:

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

5469:Antonidas

题目描述
Given a tree with $N$ vertices and $N - 1$ edges. Each vertex has a single letter $C_i$. Given a string $S$, you are to choose two vertices A and B, and make sure the letters catenated on the shortest path from A to B is exactly S. Now, would you mind telling me whether the path exists?
输入解释
The first line is an integer T, the number of test cases.
For each case, the first line is an integer $N$. Following $N - 1$ lines contains two integers a and b, meaning there is an edge connect vertex a and vertex b.
Next line contains a string C, the length of C is exactly $N$. String C represents the letter on each vertex.
Next line contains a string S.
$1 \leq T \leq 200$, $1 \leq N \leq 10^4$, $1 \leq a, b \leq N$, $a \neq b$, $|C| = N$, $1 \leq |S| \leq 10^4$. String C and S both only contain lower case letters.
输出解释
First, please output "Case #k: ", k is the number of test case. See sample output for more detail.
If the path exists, please output “Find”. Otherwise, please output “Impossible”.
输入样例
2

7
1 2
2 3
2 4
1 5
5 6
6 7
abcdefg
dbaefg

5
1 2
2 3
2 4
4 5
abcxy
yxbac
输出样例
Case #1: Find
Case #2: Impossible
来自杭电HDUOJ的附加信息
Recommend hujie

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

源链接: HDU-5469

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

共提交 0

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