問題一覧 > 通常問題

No.938 Find the Wise

レベル : / AI推定難易度 : 214 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 246
作問者 : B0_0L / テスター : mai
お気に入りにしたユーザー ProblemId : 3601 / 自分の提出
問題文最終更新日: 2019-12-01 18:14:22
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
Advent Calendar Contest 2019 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。