結果

問題 No.92 逃走経路
ユーザー tobusakanatobusakana
提出日時 2022-11-27 15:59:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 694 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 82,536 KB
実行使用メモリ 68,456 KB
最終ジャッジ日時 2024-04-14 23:33:13
合計ジャッジ時間 2,250 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 36 ms
52,480 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# dp[i] = 街iにいる可能性があればTrue
# O(MK)
import sys
readline = sys.stdin.readline
N,M,K = map(int,readline().split())
G = [[] for i in range(N)]
for _ in range(M):
    a,b,c = map(int,readline().split())
    G[a - 1].append([b - 1, c])
    G[b - 1].append([a - 1, c])

D = list(map(int,readline().split()))
dp = [True] * N
for d in D:
    new_dp = [False] * N
    for v in range(N):
        if not dp[v]:
            continue
        for child,cost in G[v]:
            if cost != d:
                continue
            new_dp[child] = True
    dp = new_dp

ans = []
for i in range(N):
    if dp[i]:
        ans.append(i + 1)
        
print(len(ans))
for a in ans:
    print(a)
0