結果
問題 | No.92 逃走経路 |
ユーザー |
|
提出日時 | 2022-09-08 00:11:34 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 571 ms / 5,000 ms |
コード長 | 723 bytes |
コンパイル時間 | 115 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,904 KB |
最終ジャッジ日時 | 2024-11-23 15:32:46 |
合計ジャッジ時間 | 5,627 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
from collections import defaultdict, dequen, m, k = map(int, input().split())edge = defaultdict(list)for _ in range(m):a, b, c = map(int, input().split())edge[a].append((b, c))edge[b].append((a, c))D = [0] + list(map(int, input().split()))Que = deque()for i in range(1, n + 1):Que.append((i, 0))ANS = []Seen = [[False for _ in range(n + 1)] for _ in range(k + 1)]while Que:cp, cnt = Que.popleft()if cnt == k:ANS.append(cp)continuefor np, c in edge[cp]:if D[cnt + 1] != c:continueif Seen[cnt + 1][np]:continueSeen[cnt + 1][np] = TrueQue.append((np, cnt + 1))ANS.sort()print(len(ANS))print(*ANS)