ΠΠ°Π΄Π°ΡΠ°: Π£ ΠΊΠ°ΠΆΠ΄ΠΎΠΉ ΠΊΠΎΡΠΊΠΈ Π΅ΡΡΡ ΠΈΠΌΡ ΠΈ ΠΊΠΎΡΠΊΠ°-ΠΌΠ°ΠΌΠ°.
Π‘ΠΎΠ·Π΄Π°ΡΡ ΠΊΠ»Π°ΡΡ, ΠΊΠΎΡΠΎΡΡΠΉ Π±Ρ ΠΎΠΏΠΈΡΡΠ²Π°Π» Π΄Π°Π½Π½ΡΡ ΡΠΈΡΡΠ°ΡΠΈΡ.
Π‘ΠΎΠ·Π΄Π°ΡΡ Π΄Π²Π° ΠΎΠ±ΡΠ΅ΠΊΡΠ°: ΠΊΠΎΡΠΊΡ-Π΄ΠΎΡΡ ΠΈ ΠΊΠΎΡΠΊΡ-ΠΌΠ°ΠΌΡ.
ΠΡΠ²Π΅ΡΡΠΈ ΠΈΡ
Π½Π° ΡΠΊΡΠ°Π½.
ΠΠΎΠ²Π°Ρ Π·Π°Π΄Π°ΡΠ°: Π£ ΠΊΠ°ΠΆΠ΄ΠΎΠΉ ΠΊΠΎΡΠΊΠΈ Π΅ΡΡΡ ΠΈΠΌΡ, ΠΊΠΎΡΠΊΠ°-ΠΏΠ°ΠΏΠ° ΠΈ ΠΊΠΎΡΠΊΠ°-ΠΌΠ°ΠΌΠ°.
ΠΠ·ΠΌΠ΅Π½ΠΈΡΡ ΠΊΠ»Π°ΡΡ Cat ΡΠ°ΠΊ, ΡΡΠΎΠ±Ρ ΠΎΠ½ ΠΌΠΎΠ³ ΠΎΠΏΠΈΡΠ°ΡΡ Π΄Π°Π½Π½ΡΡ ΡΠΈΡΡΠ°ΡΠΈΡ.
Π‘ΠΎΠ·Π΄Π°ΡΡ 6 ΠΎΠ±ΡΠ΅ΠΊΡΠΎΠ²: Π΄Π΅Π΄ΡΡΠΊΡ (ΠΏΠ°ΠΏΠΈΠ½ ΠΏΠ°ΠΏΠ°), Π±Π°Π±ΡΡΠΊΡ (ΠΌΠ°ΠΌΠΈΠ½Π° ΠΌΠ°ΠΌΠ°), ΠΏΠ°ΠΏΡ, ΠΌΠ°ΠΌΡ, ΡΡΠ½Π°, Π΄ΠΎΡΡ.
ΠΡΠ²Π΅ΡΡΠΈ ΠΈΡ
Π²ΡΠ΅Ρ
Π½Π° ΡΠΊΡΠ°Π½ Π² ΠΏΠΎΡΡΠ΄ΠΊΠ΅: Π΄Π΅Π΄ΡΡΠΊΠ°, Π±Π°Π±ΡΡΠΊΠ°, ΠΏΠ°ΠΏΠ°, ΠΌΠ°ΠΌΠ°, ΡΡΠ½, Π΄ΠΎΡΡ.
Π Π΅Π·ΡΠ»ΡΡΠ°Ρ ΡΠ°Π±ΠΎΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ:
Cat name is Π΄Π΅Π΄ΡΡΠΊΠ° ΠΠ°ΡΡ, no mother, no father
Cat name is Π±Π°Π±ΡΡΠΊΠ° ΠΡΡΠΊΠ°, no mother, no father
Cat name is ΠΏΠ°ΠΏΠ° ΠΠΎΡΠΎΡΠ΅ΠΉ, no mother, father is Π΄Π΅Π΄ΡΡΠΊΠ° ΠΠ°ΡΡ
Cat name is ΠΌΠ°ΠΌΠ° ΠΠ°ΡΠΈΠ»ΠΈΡΠ°, no mother, father is Π±Π°Π±ΡΡΠΊΠ° ΠΡΡΠΊΠ°
Cat name is ΡΡΠ½ ΠΡΡΡΠΈΠΊ, mother is ΠΌΠ°ΠΌΠ° ΠΠ°ΡΠΈΠ»ΠΈΡΠ°, father is ΠΏΠ°ΠΏΠ° ΠΠΎΡΠΎΡΠ΅ΠΉ
Cat name is Π΄ΠΎΡΡ ΠΡΡΠΈΠ½ΠΊΠ°, mother is ΠΌΠ°ΠΌΠ° ΠΠ°ΡΠΈΠ»ΠΈΡΠ°, father is ΠΏΠ°ΠΏΠ° ΠΠΎΡΠΎΡΠ΅ΠΉ
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String grandfatherName = reader.readLine();
Cat catGrandfather = new Cat(grandfatherName);
String grandmotherName = reader.readLine();
Cat catGrandmother = new Cat(grandmotherName);
String dadName = reader.readLine();
Cat catDad = new Cat(dadName, catGrandfather);
String motherName = reader.readLine();
Cat catMother = new Cat(motherName, catGrandmother);
String sonName = reader.readLine();
Cat catSon = new Cat(sonName, catMother, catDad);
String daughterName = reader.readLine();
Cat catDaughter = new Cat(daughterName, catMother, catDad);
System.out.println(catGrandfather);
System.out.println(catGrandmother);
System.out.println(catDad);
System.out.println(catMother);
System.out.println(catSon);
System.out.println(catDaughter);}
public static class Cat {
private String name;
private Cat parent, parent1;
Cat(String name) {
this.name = name;
}
Cat(String name, Cat parent) {
this.name = name;
this.parent = parent;
}
Cat(String name, Cat parent, Cat parent1) {
this.name = name;
this.parent = parent;
this.parent1 = parent1;
}
@Override
public String toString() {
if (parent == null && parent1 == null)
return "Cat name is " + name + ", no mother, no father";
if (parent1 == null)
return "Cat name is " + name + ", no mother, father is " + parent.name;
if (parent == null)
return "Cat name is " + name + ", mother is " + parent1.name + ", no father" ;
else
return "Cat name is " + name + ", mother is " + parent.name + ", father is " + parent1.name;
}
}
}