QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#21047. شجرة العائلة

Statistics

لدى Farmer John مزرعة عائلية توارثتها أجيال، ويمكن تتبع عائلات الأبقار فيها لأجيال أيضًا. يراجع سجلات قديمة لمعرفة قرابة أبقار قطيعه الحالي. ساعده!

الإدخال

السطر الأول: $N$ ($1 \leq N \leq 100$) ثم اسما بقرتين. الاسم سلسلة حتى $10$ أحرف كبيرة ($A \ldots Z$). يريد معرفة علاقتهما.

الأسطر $N$ التالية تحوي $X$ و$Y$، أي $X$ أم $Y$.

الإخراج

اطبع سطرًا يبين علاقة البقرتين في السطر الأول (نسميهما BESSIE وELSIE أدناه للتبسيط). الأنواع الممكنة:

  • إن كانت أمهما واحدة، اطبع SIBLINGS.

  • قد تكون BESSIE سليلة مباشرة لـELSIE، فتكون ELSIE أمها أو جدتها أو أم جدتها أو جدة جدتها إلخ. اطبع ELSIE is the (relation) of BESSIE بالعلاقة المناسبة مثل great-great-grand-mother.

  • إن كانت ELSIE ابنة سلف لـBESSIE (وليست نفسها سلفًا أو أختًا)، فهي خالتها. ابنة الجدة: ELSIE is the aunt of BESSIE؛ ابنة أم الجدة: ELSIE is the great-aunt of BESSIE؛ ابنة جدة الجدة: ELSIE is the great-great-aunt of BESSIE، وهكذا.

  • إن كانتا قريبتين بغير ذلك (سلف مشترك)، فهما من بنات العمومة: اطبع COUSINS.

  • إن لم يوجد سلف مشترك، أو لم تكن أي منهما سليلة مباشرة للأخرى، اطبع NOT RELATED.

يوضح الرسم العلاقات الوحيدة المطلوبة. «ابنة الأخت» غير لازمة: إن كانت BESSIE ابنة أخت ELSIE، فـELSIE خالتها.

fig_familytree_bronze_open18.png

أمثلة

الإدخال 1

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

الإخراج 1

BB is the great-aunt of AA

مؤلف المسألة: 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.