結果
| 問題 |
No.92 逃走経路
|
| コンテスト | |
| ユーザー |
threepipes_s
|
| 提出日時 | 2015-12-31 15:56:35 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 650 bytes |
| コンパイル時間 | 258 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 17,424 KB |
| 最終ジャッジ日時 | 2024-09-19 08:58:43 |
| 合計ジャッジ時間 | 7,946 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 3 TLE * 1 -- * 14 |
ソースコード
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())
threepipes_s