結果

問題 No.92 逃走経路
ユーザー brthyyjpbrthyyjp
提出日時 2022-03-17 15:59:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 64 ms / 5,000 ms
コード長 621 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 68,440 KB
最終ジャッジ日時 2024-04-08 21:19:55
合計ジャッジ時間 2,015 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
66,356 KB
testcase_01 AC 40 ms
53,460 KB
testcase_02 AC 43 ms
53,460 KB
testcase_03 AC 40 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 54 ms
62,192 KB
testcase_06 AC 55 ms
64,276 KB
testcase_07 AC 56 ms
64,276 KB
testcase_08 AC 47 ms
62,084 KB
testcase_09 AC 51 ms
62,224 KB
testcase_10 AC 56 ms
64,280 KB
testcase_11 AC 56 ms
64,280 KB
testcase_12 AC 59 ms
66,328 KB
testcase_13 AC 52 ms
64,304 KB
testcase_14 AC 53 ms
64,284 KB
testcase_15 AC 57 ms
66,364 KB
testcase_16 AC 60 ms
68,436 KB
testcase_17 AC 64 ms
68,440 KB
testcase_18 AC 60 ms
66,356 KB
testcase_19 AC 60 ms
66,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

n, m, k = map(int, input().split())
g = [[] for i in range(n)]
for i in range(m):
    a, b, c = map(int, input().split())
    a, b = a-1, b-1
    g[a].append((c, b))
    g[b].append((c, a))
D = list(map(int, input().split()))
dp = [True]*n
for i, d in enumerate(D):
    nx = [False]*n
    for v in range(n):
        if not dp[v]:
            continue
        for c, u in g[v]:
            if c == d:
                nx[u] = True
    dp = nx
ans = []
for v in range(n):
    if dp[v]:
        ans.append(v+1)
print(len(ans))
print(*ans)
0