結果

問題 No.92 逃走経路
ユーザー c-yanc-yan
提出日時 2021-02-11 00:18:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 495 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 10,840 KB
実行使用メモリ 12,788 KB
最終ジャッジ日時 2023-09-22 20:55:14
合計ジャッジ時間 9,350 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 543 ms
8,608 KB
testcase_01 AC 15 ms
7,804 KB
testcase_02 AC 15 ms
7,752 KB
testcase_03 AC 16 ms
7,744 KB
testcase_04 AC 15 ms
7,788 KB
testcase_05 AC 398 ms
8,304 KB
testcase_06 AC 21 ms
8,444 KB
testcase_07 AC 20 ms
8,544 KB
testcase_08 AC 16 ms
7,820 KB
testcase_09 AC 902 ms
7,776 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, K = map(int, input().split())
abc = [tuple(map(int, input().split())) for _ in range(M)]
d = list(map(int, input().split()))

links = {}
for a, b, c in abc:
    links.setdefault(c, [])
    links[c].append((a - 1, b - 1))

q = set(range(N))
for k in range(K):
    nq = set()
    l = links[d[k]]
    for i in q:
        for a, b in l:
            if i == a:
                nq.add(b)
            if i == b:
                nq.add(a)
    q = nq
print(len(q))
print(*sorted(i + 1 for i in q))
0