結果

問題 No.938 賢人を探せ
ユーザー neterukunneterukun
提出日時 2019-12-01 00:04:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 82,192 KB
実行使用メモリ 91,264 KB
最終ジャッジ日時 2024-05-08 08:51:52
合計ジャッジ時間 3,184 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
91,136 KB
testcase_01 AC 39 ms
51,968 KB
testcase_02 AC 39 ms
52,096 KB
testcase_03 AC 37 ms
51,968 KB
testcase_04 AC 38 ms
52,224 KB
testcase_05 AC 42 ms
51,840 KB
testcase_06 AC 39 ms
52,352 KB
testcase_07 AC 40 ms
52,352 KB
testcase_08 AC 105 ms
83,120 KB
testcase_09 AC 107 ms
83,984 KB
testcase_10 AC 37 ms
52,096 KB
testcase_11 AC 112 ms
84,804 KB
testcase_12 AC 111 ms
83,968 KB
testcase_13 AC 109 ms
83,968 KB
testcase_14 AC 111 ms
83,840 KB
testcase_15 AC 116 ms
83,972 KB
testcase_16 AC 114 ms
83,896 KB
testcase_17 AC 114 ms
83,968 KB
testcase_18 AC 114 ms
83,880 KB
testcase_19 AC 116 ms
83,836 KB
testcase_20 AC 111 ms
83,940 KB
testcase_21 AC 110 ms
84,096 KB
testcase_22 AC 121 ms
91,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
info = [input().split() for i in range(n)]

to_int = {}
to_str = {}
cnt = 0
for i in range(n):
    a, b = info[i]
    if a not in to_int:
        to_int[a] = cnt
        to_str[cnt] = a
        cnt += 1
    if b not in to_int:
        to_int[b] = cnt
        to_str[cnt] = b
        cnt += 1

graph = [[] for i in range(cnt)]
for i in range(n):
    a, b = info[i]
    a, b = to_int[a], to_int[b]
    graph[a].append(b)

for i in range(cnt):
    if len(graph[i]) == 0:
        print(to_str[i])
0