結果
問題 | No.2771 Personal Space |
ユーザー | nikoro256 |
提出日時 | 2024-06-01 02:06:32 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,086 ms / 2,000 ms |
コード長 | 756 bytes |
コンパイル時間 | 300 ms |
コンパイル使用メモリ | 82,312 KB |
実行使用メモリ | 129,832 KB |
最終ジャッジ日時 | 2024-06-01 02:07:02 |
合計ジャッジ時間 | 23,978 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
53,036 KB |
testcase_01 | AC | 1,074 ms
129,828 KB |
testcase_02 | AC | 1,069 ms
128,628 KB |
testcase_03 | AC | 1,079 ms
129,832 KB |
testcase_04 | AC | 1,081 ms
129,376 KB |
testcase_05 | AC | 1,086 ms
129,552 KB |
testcase_06 | AC | 1,073 ms
129,832 KB |
testcase_07 | AC | 543 ms
78,496 KB |
testcase_08 | AC | 489 ms
76,944 KB |
testcase_09 | AC | 547 ms
78,432 KB |
testcase_10 | AC | 936 ms
112,760 KB |
testcase_11 | AC | 1,068 ms
121,876 KB |
testcase_12 | AC | 1,028 ms
115,248 KB |
testcase_13 | AC | 523 ms
79,200 KB |
testcase_14 | AC | 573 ms
78,956 KB |
testcase_15 | AC | 625 ms
81,844 KB |
testcase_16 | AC | 634 ms
83,076 KB |
testcase_17 | AC | 694 ms
88,476 KB |
testcase_18 | AC | 565 ms
77,948 KB |
testcase_19 | AC | 569 ms
78,564 KB |
testcase_20 | AC | 1,059 ms
121,472 KB |
testcase_21 | AC | 1,012 ms
121,308 KB |
testcase_22 | AC | 1,050 ms
119,408 KB |
testcase_23 | AC | 1,081 ms
128,344 KB |
testcase_24 | AC | 1,074 ms
120,136 KB |
ソースコード
import heapq T = int(input()) for _ in range(T): N, M = map(int, input().split()) ans = [-1] * N ans[M - 1] = 1 hq = [] # (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 = 1 while len(hq) != 0: count += 1 dis, pos, left, right = heapq.heappop(hq) ans[pos] = count if left != -1 and pos - left != 1: next = (pos + left) // 2 heapq.heappush(hq, (-(next - left), next, left, pos)) if right != -1 and right - pos != 1: next = (pos + right) // 2 heapq.heappush(hq, (-(next - pos), next, pos, right)) print(*ans)