-->
当前位置:首页 > 题库

PROGRAMMING:Looking for friends

Luz5年前 (2021-05-10)题库442
Xiao a is a single dog. He has many good friends. They usually like to go out to parties and travel. Each party will take a group photo and upload it to the group for sharing. One day, Xiao a will organize the photos and want to see the situation of their group friends through the photos. Let's assume that in the same photo at the same time, both of them are good friends, and their friends are also good friends. So the question is, can you help a determine whether any two people are good friends?
###Input format:
First, input the number of photos n (n < 10000), then n lines, and input the situation in the photos according to the following format:
```
K P1 P2 P3 …… PK
```
Where k is the number of people in the photo, and the K numbers behind are the number of people in the photo. We assume that the number of people is no more than 10000 starting from 1.
Next, output the number of queries t (T < 10000), and then enter two numbers for each row, which are the numbers of the two people to query.
###Output format:
First, output the number of base friend circles and all the numbers. Then query group T and output the query results in one line. If two are good base friends, output 'yes', otherwise output' no '.
###Input example:
Here is a set of inputs. For example:
```in
four
3 11 1 2
3 3 4 10
4 1 5 7 8
3 9 6 12
two
10 5
7 11
```
###Output example:
The corresponding output is given here. For example:
```out
3 12
No
Yes
```







answer:If there is no answer, please comment