結果

問題 No.938 賢人を探せ
ユーザー mkawa2mkawa2
提出日時 2019-12-01 11:27:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 739 bytes
コンパイル時間 501 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 17,412 KB
最終ジャッジ日時 2023-08-21 03:29:47
合計ジャッジ時間 2,453 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
17,360 KB
testcase_01 AC 15 ms
7,908 KB
testcase_02 AC 17 ms
7,864 KB
testcase_03 AC 16 ms
7,884 KB
testcase_04 AC 16 ms
7,880 KB
testcase_05 AC 16 ms
7,956 KB
testcase_06 AC 16 ms
7,784 KB
testcase_07 AC 16 ms
7,864 KB
testcase_08 AC 60 ms
12,344 KB
testcase_09 AC 61 ms
12,020 KB
testcase_10 AC 16 ms
7,868 KB
testcase_11 AC 75 ms
16,452 KB
testcase_12 AC 59 ms
11,736 KB
testcase_13 AC 58 ms
11,636 KB
testcase_14 AC 60 ms
11,752 KB
testcase_15 AC 59 ms
11,628 KB
testcase_16 AC 62 ms
11,580 KB
testcase_17 AC 61 ms
11,708 KB
testcase_18 AC 60 ms
11,620 KB
testcase_19 AC 59 ms
11,600 KB
testcase_20 AC 57 ms
11,744 KB
testcase_21 AC 58 ms
11,736 KB
testcase_22 AC 96 ms
17,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    ok = set()
    ng = set()
    name_to_i = {}
    n = int(input())
    for i in range(n):
        ng_name, ok_name = input().split()
        ok.add(ok_name)
        ng.add(ng_name)
        if ng_name not in name_to_i:
            name_to_i[ng_name] = i * 2
        if ok_name not in name_to_i:
            name_to_i[ok_name] = i * 2 + 1
    ok -= ng
    for name in sorted(ok, key=lambda x: name_to_i[x]):
        print(name)

main()
0