結果

問題 No.92 逃走経路
ユーザー kutsutama
提出日時 2018-12-30 02:53:02
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 693 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 77,348 KB
最終ジャッジ日時 2024-10-04 10:45:05
合計ジャッジ時間 12,475 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 2
other TLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections

n, m, k = [int(x) for x in input().split()]
town = [[] for _ in range(n + 1)]
for i in range(m):
    a, b, c = [int(x) for x in input().split()]
    town[a] += [(b, c)]
    town[b] += [(a, c)]
d = [int(x) for x in input().split()]

cand = set()
for i in range(1, len(town)):
    tovisit = collections.deque()
    tovisit.append((i, 0))
    while len(tovisit) >= 1:
        now, cnt = tovisit.popleft()
        if cnt >= len(d):
            cand.add(now)
            continue
        for nex, cost in town[now]:
            if d[cnt] == cost:
                tovisit.append((nex, cnt + 1))
res = list(cand)
res.sort()

print(len(res))
print(*res)
0