No.938 Find the Wise
Problem Statement
At a certain school, final exams ended the other day, and the students shut themselves in at karaoke.
The teacher shut himself in at school to grade the exams, but then a problem arose.
All the answers are identical! Realizing that cheating had occurred, the teacher decided to give an A grade only to the students who answered without copying anyone's answers.
As it happens, the exam proctor had noted down everything about who cheated off whom.
Given the notes, output the students who should receive an A grade (from the right-hand side of the lines from the 2nd line onward), in the order of the information for B.
Input
$N$ $A_1 B_1$ ⋮ $A_n B_n$
The number of entries N($1 \le N \le 20000$) is given on the first line.
Each of the following lines, from line 2 to line (N+1), gives the information that $A_i$ cheated off $B_i$.
$A_i$ and $B_i$ are strings of English letters of length at most 10. ( $1 \le |A|, |B| \le 10 $)
A person who cheats does not cheat off two or more people.
Also, no one cheats off themselves.
The proctor does not take duplicate notes. That is, if $i \neq j$, then $A_i \neq A_j$ is guaranteed.)
・Constraints (the Tester took care of this!!)
Output
Output the students who can receive an A grade, in the order given in the input, separated by newlines.
It is guaranteed that at least one student can receive it.
Sample
Sample 1
Input
3 Lily John Bob Lily Ema John
Output
John
Lily cheated off John.
Bob cheated off Lily.
Ema cheated off John.
From this information, John, who did not cheat, can receive an A grade.
Sample 2
Input
3 Higuchi Ichiyo Hukuzawa Yukichi Noguchi Hideyo
Output
Ichiyo Yukichi Hideyo
There is not necessarily only one student who can receive an A grade.
Also, your answer will be judged incorrect unless you output in the order of the information.
Yukichi
Hideyo
Ichiyo is not acceptable. (This is due to my lack of skill...)
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
B0_0L