結果
問題 | No.2771 Personal Space |
ユーザー |
![]() |
提出日時 | 2024-06-01 02:06:32 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,197 ms / 2,000 ms |
コード長 | 756 bytes |
コンパイル時間 | 2,174 ms |
コンパイル使用メモリ | 82,128 KB |
実行使用メモリ | 129,688 KB |
最終ジャッジ日時 | 2024-12-21 04:19:09 |
合計ジャッジ時間 | 27,142 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 24 |
ソースコード
import heapqT = int(input())for _ in range(T):N, M = map(int, input().split())ans = [-1] * Nans[M - 1] = 1hq = []# (distance,pos,left,right)if M - 1 != 0:heapq.heappush(hq, (-(M - 1), 0, -1, M - 1))if M != N:heapq.heappush(hq, (-(N - M), N - 1, M - 1, -1))count = 1while len(hq) != 0:count += 1dis, pos, left, right = heapq.heappop(hq)ans[pos] = countif left != -1 and pos - left != 1:next = (pos + left) // 2heapq.heappush(hq, (-(next - left), next, left, pos))if right != -1 and right - pos != 1:next = (pos + right) // 2heapq.heappush(hq, (-(next - pos), next, pos, right))print(*ans)