#P3323. [SDOI2015] 旅行计划
[SDOI2015] 旅行计划
Description
In a country with cities, Alice wants to embark on a legendary journey. They wish to start from a city, each time moving to an adjacent city, visit exactly cities without repetition along the way, and finally arrive at another city to end the journey.
Note that the starting city and the ending city are also counted among the visited cities. That is, including the start and end, all visited cities must be distinct. Now, Alice wants to know which ordered city pairs can serve as a valid start and end for such a journey.
Input Format
Each test file contains multiple test cases.
The first line contains a positive integer , the number of test cases.
For each test case, the first line contains three integers , , and , denoting the number of cities, the number of adjacency relations between cities, and the number of cities that the trip should visit.
The next lines each contain two integers and , indicating that city and city are adjacent, i.e., you can travel from either city to the other.
, , , and $T\times \left\lfloor \frac k 2 \right\rfloor^{\left\lfloor \frac k 2 \right\rfloor}\le 60$.
Output Format
For each test case, output lines, each containing characters. In the -th row, the -th character is either Y or N, indicating whether there exists a valid travel plan starting from city and ending at city .
1
5 6 4
1 2
2 3
3 5
1 4
4 5
2 5
NYYYY
YNNYY
YNNYN
YYYNY
YYNYN
Hint
2024-11-15: Added hack testdata.
Translated by ChatGPT 5
京公网安备 11011102002149号