시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 256 MB | 5 | 4 | 3 | 75.000% |
The English language abounds with terms for describing family (genetic) relationships. The basic relationships are:
These relationships are extended to later generations as follows:
Write a program to determine the relationship of one person to another.
Input will consist of one or more datasets. Each dataset consists of a single line containing two integers A and B (0 <= A, B <= 32767) and a character. A negative number for the first integer indicates end of input.
The integers identify persons A and B. The character will be either M or F, designating the gender of person B as male or female.
The integers identify the positions of person A and person B in a family tree envisioned as follows: consider a full binary tree in which the root is numbered 0, its children are numbered 1 and 2, the children of 1 are 3 and 4, the children of 2 are 5 and 6, and numbering proceeds in that manner, level by level, left to right. This numbering scheme is shown in the diagram below. A parent-child relationship in this tree represents a parent-child relationship in the family.
For each dataset, print a single line indicating the relationship of B to A. This relationship must be constructed from the phrases "self", "sister", "brother", "daughter", "son", "mother", "father", "niece", "nephew", "aunt", "uncle", "cousin", "grand", "great-", "1st", "2nd", "3rd", "once removed", "twice removed", and "thrice removed". No more than two "great-" prefixes may be applied. If "1st", "2nd", or "3rd" is used, it should be separated from the following part of the line by a single blank. If "once removed", "twice removed", or "thrice removed" is used, it must be separated from the preceding part of the line by a single blank. If it is not possible to describe the relationship of B to A under the above limitations, then print "kin".
1 5 M 0 0 M 1 11 F 0 8 F 5 7 M 0 32767 F -1 -1 M
nephew self grandniece great-granddaughter 1st cousin once removed kin