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

PROGRAMMING:May all lovers in the world be brothers and sisters who have been separated for many years

Luz5年前 (2021-05-10)题库468
ha-ha. As we all know, intermarriage is not allowed within five clothes, that is, if the nearest common ancestor of two people is within five generations (i.e. himself, his parents, grandparents, great grandparents and great grandparents), intermarriage is not allowed. Please help a couple to judge whether they can get married or not?
###Input format:
Enter the first line to give a positive integer 'n' (2 $$$Le $$'n '$$Le 10 ^ 4 $$). Next, enter the' n 'line, and each line gives a person's information in the following format:
```
I ID gender father ID mother ID
```
The 'ID' is a five digit number, which is different for each person; Gender'm 'stands for male and' f 'stands for female. If one's father or mother is no longer available, the corresponding 'ID' position is marked with '- 1'.
Next, a positive integer 'k' is given, followed by 'k' lines. Each line gives a pair of lovers' IDS, separated by spaces.
Note: the title guarantees that two people are of the same generation, each of them has only one gender, and there is no incest or intergenerational marriage in the blood relationship network.
###Output format:
For each pair of lovers, judge whether their relationship can be intermarried: if they are of the same sex, output 'never mind'; If you are of the opposite sex and have five clothes, output "yes"; If the heterosexual relationship does not produce five clothes, output 'no'.
###Input example:
```in
twenty-four
00001 M 01111 -1
00002 F 02222 03333
00003 M 02222 03333
00004 F 04444 03333
00005 M 04444 05555
00006 F 04444 05555
00007 F 06666 07777
00008 M 06666 07777
00009 M 00001 00002
00010 M 00003 00006
00011 F 00005 00007
00012 F 00008 08888
00013 F 00009 00011
00014 M 00010 09999
00015 M 00010 09999
00016 M 10000 00012
00017 F -1 00012
00018 F 11000 00013
00019 F 11100 00018
00020 F 00015 11110
00021 M 11100 00020
00022 M 00016 -1
00023 M 10012 00017
00024 M 00022 10013
nine
00021 00024
00019 00024
00011 00012
00022 00018
00001 00004
00013 00016
00017 00015
00019 00021
00010 00011
```
###Output example:
```out
Never Mind
Yes
Never Mind
No
Yes
No
Yes
No
No
```






answer:If there is no answer, please comment