結果

問題 No.3590 I Love Inversions
コンテスト
ユーザー flippergo
提出日時 2026-11-17 09:11:10
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 3,009 ms / 5,000 ms
+ 0µs
コード長 924 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 79 ms
コンパイル使用メモリ 64,340 KB
実行使用メモリ 71,620 KB
平均クエリ数 12103.46
最終ジャッジ日時 2026-11-17 09:12:14
合計ジャッジ時間 34,550 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(input())
if N==1:
    print("! 1")
else:
    S = []
    for i in range(2,N+1):
        print(f"? {1} {i}")
        S.append(int(input()))
    X = [0,S[0]]
    for i in range(1,N-1):
        X.append(S[i]-S[i-1])
    K = 0
    while 1<<K < N:
        K += 1
    M = 1<<K
    T = [0]*(M+1)
    def bit_sum(i,x):
        j = i
        while j<=M:
            T[j] += x
            j += j&(-j)
    def bit_cum(i):
        cnt = 0
        j = i
        while j>0:
            cnt += T[j]
            j -= j&(-j)
        return cnt
    for i in range(1,N+1):
        bit_sum(i,1)
    P = []
    while X:
        x = X.pop()
        tot = T[M]-x
        high = N
        low = 0
        while high-low>1:
            mid = (high+low)//2
            if bit_cum(mid)>=tot:
                high = mid
            else:
                low = mid
        P.append(high)
        bit_sum(high,-1)
    P = P[::-1]
    print("!",*P)
0