#P2256. 一中校运会之百米跑
一中校运会之百米跑
Description
Suppose there are () competitors.
The teacher will tell you the names of these competitors.
Then the teacher will say () sentences, each stating that student A and student B are in the same group.
If student A and student B are in the same group, and student B and student C are also in the same group, then student A and student C are in the same group.
After that, the teacher will ask you () questions, each asking whether student X and student Y are in the same group.
If they are, output Yes.; otherwise, output No..
Input Format
The first line contains and .
The next lines each contain the name of one student.
The next lines each contain two names, both guaranteed to have appeared in the above lines, indicating that these two competitors are in the same group.
Then an integer is given.
Then follow queries. Each query consists of two names, asking whether the two students are in the same group.
Output Format
For each of the teacher’s queries, output Yes. or No..
10 6
Jack
Mike
ASDA
Michel
brabrabra
HeHe
HeHE
papapa
HeY
Obama
Jack Obama
HeHe HeHE
brabrabra HeHe
Obama ASDA
papapa Obama
Obama HeHE
3
Mike Obama
HeHE Jack
papapa brabrabra
No.
Yes.
Yes.
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号