結果

問題 No.92 逃走経路
ユーザー kutsutamakutsutama
提出日時 2018-12-30 02:53:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 693 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 64,412 KB
最終ジャッジ日時 2024-04-15 02:23:28
合計ジャッジ時間 12,448 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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