QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 256 MB Points totaux : 100

#21047. Albero genealogico

Statistiques

Farmer John possiede una fattoria familiare tramandata per generazioni, e anche le genealogie delle mucche risalgono a generazioni nella fattoria. Studia vecchi registri per conoscerne i legami attuali. Aiutalo!

Input

Prima riga: $N$ ($1 \leq N \leq 100$) e nomi di due mucche. Ogni nome ha al massimo $10$ maiuscole ($A \ldots Z$). Vuole sapere la relazione fra queste due.

Le successive $N$ righe contengono $X$ e $Y$, indicando che $X$ è madre di $Y$.

Output

Stampa una riga con la relazione delle due mucche iniziali (chiamate BESSIE ed ELSIE sotto per semplicità). Tipi possibili:

  • Se hanno la stessa madre, stampa SIBLINGS.

  • BESSIE può discendere direttamente da ELSIE, che è sua madre, nonna, bisnonna, trisnonna, ecc. Stampa ELSIE is the (relation) of BESSIE, con la relazione appropriata, ad esempio great-great-grand-mother.

  • Se ELSIE è figlia di un’antenata di BESSIE (senza essere antenata o sorella), è sua zia. Figlia della nonna: ELSIE is the aunt of BESSIE; bisnonna: ELSIE is the great-aunt of BESSIE; trisnonna: ELSIE is the great-great-aunt of BESSIE, ecc.

  • Se sono legate altrimenti (antenata comune), sono cugine: stampa COUSINS.

  • Senza antenata comune, o se nessuna discende direttamente dall’altra, stampa NOT RELATED.

Il diagramma mostra le uniche relazioni da considerare. «Nipote» (figlia di sorella) non serve: se BESSIE è nipote di ELSIE, ELSIE è sua zia.

fig_familytree_bronze_open18.png

Esempi

Input 1

7 AA BB
MOTHER AA
GGMOTHER BB
MOTHER SISTER
GMOTHER MOTHER
GMOTHER AUNT
AUNT COUSIN
GGMOTHER GMOTHER

Output 1

BB is the great-aunt of AA

Autore del problema: Brian Dean

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.