結果

問題 No.92 逃走経路
ユーザー threepipes_sthreepipes_s
提出日時 2015-12-31 15:56:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 650 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 11,956 KB
実行使用メモリ 16,920 KB
最終ジャッジ日時 2023-10-19 12:52:40
合計ジャッジ時間 7,875 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 450 ms
16,920 KB
testcase_01 AC 33 ms
10,504 KB
testcase_02 AC 32 ms
10,504 KB
testcase_03 AC 33 ms
10,504 KB
testcase_04 AC 32 ms
10,504 KB
testcase_05 TLE -
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 #

from queue import Queue

used = set()
n, m, k = map(int, input().split())
node = [[] for i in range(n)]
for i in range(m):
    a, b, c = map(int, input().split())
    node[a-1].append((b-1, c))
    node[b-1].append((a-1, c))
d = list(map(int, input().split()))
qu = Queue()
for i in range(n):
    qu.put((i, 0))
res = []
while not qu.empty():
    (p, t) = qu.get()
    if (p, t) in used: continue
    used.add((p, t))
    if t == k:
        res.append(p)
        continue
    for (np, c) in node[p]:
        if d[t] != c: continue
        qu.put((np, t+1))
res.sort()
print(len(res))
ans = ""
for i in res:
    ans += str(i+1)+" "
print(ans.strip())
0