結果
| 問題 | No.92 逃走経路 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-11-27 15:59:57 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 694 bytes |
| コンパイル時間 | 270 ms |
| コンパイル使用メモリ | 82,272 KB |
| 実行使用メモリ | 69,308 KB |
| 最終ジャッジ日時 | 2024-10-04 05:09:22 |
| 合計ジャッジ時間 | 2,470 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | WA * 18 |
ソースコード
# 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)