結果

問題 No.2771 Personal Space
ユーザー mkawa2mkawa2
提出日時 2024-05-31 23:44:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,113 ms / 2,000 ms
コード長 1,363 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 82,368 KB
実行使用メモリ 121,864 KB
最終ジャッジ日時 2024-05-31 23:44:42
合計ジャッジ時間 24,195 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,940 KB
testcase_01 AC 1,089 ms
121,660 KB
testcase_02 AC 1,075 ms
121,864 KB
testcase_03 AC 1,074 ms
121,400 KB
testcase_04 AC 1,098 ms
121,280 KB
testcase_05 AC 1,099 ms
121,488 KB
testcase_06 AC 1,057 ms
121,788 KB
testcase_07 AC 536 ms
80,068 KB
testcase_08 AC 250 ms
82,160 KB
testcase_09 AC 583 ms
80,768 KB
testcase_10 AC 960 ms
107,196 KB
testcase_11 AC 1,048 ms
113,928 KB
testcase_12 AC 1,027 ms
109,696 KB
testcase_13 AC 560 ms
83,048 KB
testcase_14 AC 545 ms
80,964 KB
testcase_15 AC 675 ms
85,092 KB
testcase_16 AC 645 ms
84,008 KB
testcase_17 AC 722 ms
90,472 KB
testcase_18 AC 551 ms
80,408 KB
testcase_19 AC 549 ms
80,700 KB
testcase_20 AC 1,088 ms
114,432 KB
testcase_21 AC 1,014 ms
113,612 KB
testcase_22 AC 1,089 ms
112,844 KB
testcase_23 AC 1,113 ms
118,708 KB
testcase_24 AC 1,101 ms
113,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(1000006)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = -1-(-1 << 31)
inf = -1-(-1 << 62)

# md = 10**9+7
md = 998244353

from heapq import *

def solve():
    def push(l,r):
        if l>r:return
        if l==1:
            heappush(hp, (-r+1, 1, r))
        elif r==n:
            heappush(hp,(-n+l,l,n))
        else:
            heappush(hp,(-((r-l)//2),l,r))

    n,m=LI()
    hp=[]
    push(1,m-1)
    push(m+1,n)
    ans=[0]*(n+1)
    ans[m]=1
    for a in range(2,n+1):
        _,l,r=heappop(hp)
        if l==1:
            m=1
        elif r==n:
            m=n
        else:
            m=(l+r)//2
        ans[m]=a
        push(l,m-1)
        push(m+1,r)
    print(*ans[1:])

for _ in range(II()):solve()
0