RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0329 파일 입출력

Family Tree

Bronze II 브론즈 II
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Farmer John owns a family-run farm that has been passed down over several
generations, with a herd of cows whose familial roots can similarly be traced
back several generations on the same farm. By examining old records, Farmer
John is curious how the cows in his current herd are related to each-other.
Please help him in this endeavor!

Problem credits: Brian Dean

제약

Problem credits: Brian Dean

입력 형식

The first line of input contains \(N\) (\(1 \leq N \leq 100\)) followed by the names
of two cows. Cow names are each strings of at most 10 uppercase letters
(\(A \ldots Z\)). Farmer John is curious about the relationship between the two
cows on this line of input.

The next \(N\) lines each contain two cow names \(X\) and \(Y\), indicating that \(X\)
is the mother of \(Y\).

출력 형식

You should print one line of output indicating the relationship between the two
cows specified on the first line of input (for simplicity, let's call these two
cows BESSIE and ELSIE for the examples below). Here are the different types of
relationships that are possible:

  • You should output "SIBLINGS" if BESSIE and ELSIE have the same mother.
  • BESSIE might be a direct descendant of ELSIE, meaning that ELSIE is either the mother, grand-mother, great-grand-mother, great-great-grand-mother, etc., of BESSIE. If this is the case, you should print "ELSIE is the (relation) of BESSIE", where (relation) is the appropriate relationship, for example "great-great-grand-mother".
  • If ELSIE is a child of an ancestor of BESSIE (and ELSIE is not herself an ancestor or sister of BESSIE), then ELSIE is BESSIE's aunt. You should output "ELSIE is the aunt of BESSIE" if ELSIE is a child of BESSIE's grand-mother, "ELSIE is the great-aunt of BESSIE" if ELSIE is a child of BESSIE's great-grand-mother, "ELSIE is the great-great-aunt of BESSIE" if ELSIE is a child of BESSIE's great-great-grand-mother, and so on.
  • If BESSIE and ELSIE are related by any other means (i.e., if they share a common ancestor), they are cousins, and you should simply output "COUSINS".
  • You should output "NOT RELATED" if BESSIE and ELSIE have no common ancestor, or neither is directly descended from the other.

The following diagram helps illustrate the relationships above, which are the
only relationship types you need to consider. Observe that
some relationships like "niece" (daughter of sister) are not necessary since if
BESSIE is the niece of ELSIE, then ELSIE is BESSIE's aunt.

파일 입력 / 출력
이 문제는 표준 입출력을 사용하지 않습니다. 프로그램은 다음 파일을 읽고 써야 합니다:
입력을 읽을 파일 family.in
출력을 쓸 파일 family.out
예제 1
입력
7 AA BB
MOTHER AA
GGMOTHER BB
MOTHER SISTER
GMOTHER MOTHER
GMOTHER AUNT
AUNT COUSIN
GGMOTHER GMOTHER
출력
BB is the great-aunt of AA
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2017-2018 > US Open > Bronze

태그

평가 및 의견

Family Tree

개요
출제자 난이도 Bronze II 브론즈 II 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Family Tree

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8