結果

問題 No.92 逃走経路
ユーザー DialBirdDialBird
提出日時 2017-03-18 19:21:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 519 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 10,880 KB
実行使用メモリ 9,256 KB
最終ジャッジ日時 2023-09-18 02:32:38
合計ジャッジ時間 1,713 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
9,116 KB
testcase_01 AC 18 ms
8,496 KB
testcase_02 AC 19 ms
8,596 KB
testcase_03 AC 18 ms
8,588 KB
testcase_04 AC 18 ms
8,448 KB
testcase_05 AC 22 ms
8,636 KB
testcase_06 AC 24 ms
9,256 KB
testcase_07 AC 25 ms
9,128 KB
testcase_08 AC 19 ms
8,580 KB
testcase_09 AC 50 ms
8,632 KB
testcase_10 AC 59 ms
8,620 KB
testcase_11 AC 62 ms
8,720 KB
testcase_12 AC 52 ms
8,608 KB
testcase_13 AC 36 ms
8,580 KB
testcase_14 AC 38 ms
8,612 KB
testcase_15 AC 44 ms
8,676 KB
testcase_16 WA -
testcase_17 AC 41 ms
9,048 KB
testcase_18 AC 32 ms
8,956 KB
testcase_19 AC 27 ms
8,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

N,M,K = [int(i) for i in input().split()]
G = [defaultdict(set) for i in range(N)]

for i in range(M):
    a,b,c = map(int, input().split())
    a -= 1
    b -= 1
    G[a][c].add(b)
    G[b][c].add(a)

candidates = set(range(N))
for k in map(int, input().split()):
    new_candidates = set([])
    for i in candidates:
        if k in G[i]:
            new_candidates |= G[i][k]
    candidates = new_candidates

print(len(candidates))
print(" ".join([str(i+1) for i in candidates]))
0