結果

問題 No.938 賢人を探せ
ユーザー roarisroaris
提出日時 2019-12-01 02:52:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 176 ms / 2,000 ms
コード長 474 bytes
コンパイル時間 1,152 ms
コンパイル使用メモリ 87,132 KB
実行使用メモリ 87,468 KB
最終ジャッジ日時 2023-08-21 03:28:43
合計ジャッジ時間 5,795 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 176 ms
87,056 KB
testcase_01 AC 97 ms
71,872 KB
testcase_02 AC 97 ms
71,664 KB
testcase_03 AC 96 ms
71,660 KB
testcase_04 AC 97 ms
71,456 KB
testcase_05 AC 94 ms
71,460 KB
testcase_06 AC 96 ms
71,708 KB
testcase_07 AC 95 ms
71,532 KB
testcase_08 AC 152 ms
82,768 KB
testcase_09 AC 157 ms
82,032 KB
testcase_10 AC 96 ms
71,884 KB
testcase_11 AC 161 ms
82,704 KB
testcase_12 AC 169 ms
82,656 KB
testcase_13 AC 164 ms
82,704 KB
testcase_14 AC 166 ms
82,716 KB
testcase_15 AC 166 ms
82,664 KB
testcase_16 AC 164 ms
82,684 KB
testcase_17 AC 165 ms
82,608 KB
testcase_18 AC 164 ms
82,840 KB
testcase_19 AC 164 ms
82,684 KB
testcase_20 AC 164 ms
82,852 KB
testcase_21 AC 166 ms
82,644 KB
testcase_22 AC 172 ms
87,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

N = int(input())
serial = defaultdict(int)
s1, s2 = set(), set()

for i in range(N):
    Ai, Bi = input().split()
    
    if Ai not in serial:
        serial[Ai] = i
    
    if Bi not in serial:
        serial[Bi] = i
        
    s1.add(Ai)
    s1.add(Bi)
    s2.add(Ai)
    
ans = []

for s1_i in s1:
    if s1_i not in s2:
        ans.append((s1_i, serial[s1_i]))

ans.sort(key=lambda k: k[1])

for ans_i, _ in ans:
    print(ans_i)
0