| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Announcement | Current Contest Past Contests Scheduled Contests Award Contest |
Eugenics
Description Eugenics
is the basis for our healthy development. Almost all nations are
issuing laws to enforce or advocate eugenics. According to research in
genetics, many diseases will have a high probability to be passed down
to the descendants who were born from intermarriage. Thus, preventing
intermarriage has become an important part of eugenics. In China,
it is now against the law to have intermarriage. The marriage law
states, ˇ°No marriage may be contractedˇ if the man and the woman are
lineal relatives by blood, or collateral relatives by blood up to the
third degree of kinshipˇˇ± One cannot marry his/her parents or
grandparents, nor can he/she marry his/her children or grandchildren.
Marriage with his/her sisters/brothers, cousins, aunts/uncles,
nieces/nephews is also forbidden. As a staff of the Civil Affairs
Bureau, you often have to check whether two people can have a marriage
based on the family trees given, for example: Nodes
in the family tree represent persons and the numbers on the nodes
represent names. So now if 10 and 24 come for a marriage license, by
checking family tree, it is OK and we output ˇ°marriageˇ±, if 24 and 26
come for marriage, surely it is forbidden and we output ˇ°closeˇ±. If two
people of the same gender come for license, we output ˇ°sameˇ±. Input The
input contains several lines, the first line has two integers, which
represent the names of the two persons. The following lines represent
the family tree of two persons. Each line has several integers
separated by blanks. The first number of each line represents the
number of node, and the followed integers represent the direct
descendants of he/she. The last integer of each line will be an
integer: 0 or −1, representing that the person described in this line
is male/female, respectively. The input assures that: Output The
output contains only one line and one word, representing whether the
two persons can have a marriage license. If they can, output
ˇ°marriageˇ±; if they are of the same gender, output ˇ°sameˇ±; if they are
close relatives, output ˇ°closeˇ±; if they are both same gender and close
relatives, output ˇ°sameˇ±. Sample Input Sample Output Source |
[Submit] [Go Back] [Status] [Discuss]
All Rights Reserved 2003-2006 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator