結果

問題 No.938 賢人を探せ
ユーザー neterukunneterukun
提出日時 2019-12-01 00:04:49
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 704 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 91,784 KB
最終ジャッジ日時 2023-08-21 03:24:40
合計ジャッジ時間 4,210 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
91,520 KB
testcase_01 AC 72 ms
71,456 KB
testcase_02 AC 75 ms
71,596 KB
testcase_03 AC 73 ms
71,088 KB
testcase_04 AC 74 ms
71,252 KB
testcase_05 AC 75 ms
71,092 KB
testcase_06 AC 75 ms
71,252 KB
testcase_07 AC 74 ms
71,148 KB
testcase_08 AC 133 ms
83,636 KB
testcase_09 AC 134 ms
84,488 KB
testcase_10 AC 74 ms
71,364 KB
testcase_11 AC 137 ms
85,512 KB
testcase_12 AC 137 ms
84,544 KB
testcase_13 AC 139 ms
84,452 KB
testcase_14 AC 137 ms
84,424 KB
testcase_15 AC 139 ms
84,596 KB
testcase_16 AC 136 ms
84,460 KB
testcase_17 AC 136 ms
84,456 KB
testcase_18 AC 137 ms
84,280 KB
testcase_19 AC 136 ms
84,516 KB
testcase_20 AC 136 ms
84,580 KB
testcase_21 AC 136 ms
84,564 KB
testcase_22 AC 143 ms
91,784 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