Antonidas

TimeLimit:4000MS  MemoryLimit:65536KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
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?
Input
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.
Output
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”.
SampleInput
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
SampleOutput
Case #1: Find
Case #2: Impossible
Submit
题目统计信息详细
总AC数2
通过人数2
尝试人数2
总提交量5
AC率40.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签
出处

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: