|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초||128 MB||0||0||0||0.000%|
While cleaning your parents' attic, you discovered a box containing many documents describing the relationships among your ancestors. Given these documents, you are interested in answering a number of questions about the relationships implied by the document. Fortunately, all your ancestors have unique names so it is possible to make many inferences without any confusion.
It is assumed that all relationships (implied or given) satisfy the following:
The information provided will be consistent, and you may assume there are no hidden relationships that are not explicitly stated or implied by the above rules of consistency.
The first part of the input consists of a number of lines describing the known relationships. Each relationship is listed on one line in the form:
NAME is NAME's RELATIONSHIP.
where NAME is a lowercase alphabetic word (never 'is'), and RELATIONSHIP is one of
This first part is terminated by a blank line. You may assume that there is at least one known relationship given, and there are at most 100 distinct names mentioned in the known relationships.
This is followed by a list of questions (one per line) of the form:
is NAME NAME's RELATIONSHIP?
where NAME is as before, but RELATIONSHIP is one of
All names appearing in the questions will be mentioned in the list of known relationships. The list of questions is terminated by the end of file.
For each question, print on a line yes or no if the answer of the question can be determined, or unknown if the answer may be yes or no because the sex of the relevant person(s) in the question cannot be determined from the known relationships.
john is mary's husband. john is tom's father. mary is jane's mother. jane is anna's mother. is mary john's wife? is jane mary's daughter? is tom mary's husband? is anna jane's daughter?
yes yes no unknown