QOJ.ac

QOJ

시간 제한: 2 s 메모리 제한: 256 MB 총점: 100

#21047. Árbol familiar

통계

Farmer John tiene una granja familiar transmitida por generaciones, y la genealogía de sus vacas también remonta varias generaciones en ella. Consulta registros antiguos para conocer el parentesco del rebaño actual. ¡Ayúdalo!

Entrada

Primera línea: $N$ ($1 \leq N \leq 100$) y dos nombres de vacas. Cada nombre tiene como máximo $10$ mayúsculas ($A \ldots Z$). Quiere conocer su relación.

Las siguientes $N$ líneas contienen $X$ y $Y$, indicando que $X$ es madre de $Y$.

Salida

Imprime una línea con el parentesco de las dos vacas iniciales (llamadas BESSIE y ELSIE abajo por sencillez). Tipos posibles:

  • Si comparten madre, imprime SIBLINGS.

  • BESSIE puede descender directamente de ELSIE, que será su madre, abuela, bisabuela, tatarabuela, etc. Imprime ELSIE is the (relation) of BESSIE, con la relación apropiada, como great-great-grand-mother.

  • Si ELSIE es hija de un ancestro de BESSIE (sin ser ancestro o hermana ella misma), es su tía. Hija de su abuela: ELSIE is the aunt of BESSIE; bisabuela: ELSIE is the great-aunt of BESSIE; tatarabuela: ELSIE is the great-great-aunt of BESSIE, etc.

  • Si tienen otro parentesco (ancestro común), son primas: imprime COUSINS.

  • Si no tienen ancestro común, o ninguna desciende directamente de la otra, imprime NOT RELATED.

El diagrama muestra las únicas relaciones a considerar. «Sobrina» (hija de hermana) no hace falta: si BESSIE es sobrina de ELSIE, ELSIE es su tía.

fig_familytree_bronze_open18.png

Ejemplos

Entrada 1

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

Salida 1

BB is the great-aunt of AA

Autor 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.