|시간 제한||메모리 제한||제출||정답||맞힌 사람||정답 비율|
|1 초||128 MB||20||8||8||40.000%|
The Queen of Nlogonia is a fan of mazes, and therefore the queendom’s architects built several mazes around the Queen’s palace. Every maze built for the Queen is made of rooms connected by corridors. Each corridor connects a different pair of distinct rooms and can be transversed in both directions.
The Queen loves to stroll through a maze’s rooms and corridors in the late afternoon. Her servants choose a different challenge for every day, that consists of finding a simple path from a start room to an end room in a maze. A simple path is a sequence of distinct rooms such that each pair of consecutive rooms in the sequence is connected by a corridor. In this case the first room of the sequence must be the start room, and the last room of the sequence must be the end room. The Queen thinks that a challenge is good when, among the routes from the start room to the end room, exactly one of them is a simple path. Can you help the Queen’s servants to choose a challenge that pleases the Queen?
For doing so, write a program that given the description of a maze and a list of queries defining the start and end rooms, determines for each query whether that choice of rooms is a good challenge or not.
Each test case is described using several lines. The first line contains three integers R, C and Q representing respectively the number of rooms in a maze (2 ≤ R ≤ 104), the number of corridors (1 ≤ C ≤ 105), and the number of queries (1 ≤ Q ≤ 1000). Rooms are identified by different integers from 1 to R. Each of the next C lines describes a corridor using two distinct integers A and B, indicating that there is a corridor connecting rooms A and B (1 ≤ A < B ≤ R). After that, each of the next Q lines describes a query using two distinct integers S and T indicating respectively the start and end rooms of a challenge (1 ≤ S < T ≤ R). You may assume that within each test case there is at most one corridor connecting each pair of rooms, and no two queries are the same.
The last test case is followed by a line containing three zeros.
For each test case output Q + 1 lines. In the i-th line write the answer to the i-th query. If the rooms make a good challenge, then write the character ‘Y’ (uppercase). Otherwise write the character ‘N’ (uppercase). Print a line containing a single character ‘-’ (hyphen) after each test case.
6 5 3 1 2 2 3 2 4 2 5 4 5 1 3 1 5 2 6 4 2 3 1 2 2 3 1 4 1 3 1 2 0 0 0
Y N N - N Y Y -