結果
| 問題 | 
                            No.92 逃走経路
                             | 
                    
| コンテスト | |
| ユーザー | 
                             threepipes_s
                         | 
                    
| 提出日時 | 2016-01-03 02:25:02 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1,138 ms / 5,000 ms | 
| コード長 | 668 bytes | 
| コンパイル時間 | 183 ms | 
| コンパイル使用メモリ | 12,800 KB | 
| 実行使用メモリ | 23,836 KB | 
| 最終ジャッジ日時 | 2024-09-19 10:42:27 | 
| 合計ジャッジ時間 | 9,950 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 18 | 
ソースコード
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))
    used.add((i, 0))
res = []
while not qu.empty():
    (p, t) = qu.get()
    if t == k:
        res.append(p)
        continue
    for (np, c) in node[p]:
        nt = (np, t+1)
        if d[t] != c or nt in used: continue
        used.add(nt)
        qu.put(nt)
res.sort()
print(len(res))
ans = ""
for i in res:
    ans += str(i+1)+" "
print(ans.strip())
            
            
            
        
            
threepipes_s