結果

問題 No.2577 Simple Permutation Guess
ユーザー 👑 rin204rin204
提出日時 2023-12-05 00:31:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,158 bytes
コンパイル時間 905 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 94,496 KB
平均クエリ数 249.79
最終ジャッジ日時 2023-12-05 00:32:09
合計ジャッジ時間 30,889 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 QLE -
testcase_18 QLE -
testcase_19 WA -
testcase_20 QLE -
testcase_21 QLE -
testcase_22 QLE -
testcase_23 WA -
testcase_24 WA -
testcase_25 QLE -
testcase_26 QLE -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 QLE -
testcase_31 WA -
testcase_32 QLE -
testcase_33 QLE -
testcase_34 QLE -
testcase_35 QLE -
testcase_36 WA -
testcase_37 AC 63 ms
72,148 KB
testcase_38 WA -
testcase_39 AC 87 ms
72,148 KB
testcase_40 QLE -
testcase_41 QLE -
testcase_42 QLE -
testcase_43 WA -
testcase_44 QLE -
testcase_45 QLE -
testcase_46 QLE -
testcase_47 QLE -
testcase_48 QLE -
testcase_49 QLE -
testcase_50 QLE -
testcase_51 WA -
testcase_52 QLE -
testcase_53 WA -
testcase_54 WA -
testcase_55 QLE -
testcase_56 QLE -
testcase_57 WA -
testcase_58 QLE -
testcase_59 WA -
testcase_60 QLE -
testcase_61 WA -
testcase_62 QLE -
testcase_63 QLE -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 WA -
testcase_84 WA -
testcase_85 WA -
testcase_86 WA -
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 WA -
testcase_93 WA -
testcase_94 WA -
testcase_95 WA -
testcase_96 WA -
testcase_97 WA -
testcase_98 WA -
testcase_99 WA -
testcase_100 WA -
testcase_101 WA -
evil_1_rnd_1.txt WA -
evil_1_rnd_2.txt WA -
evil_2_big_1.txt WA -
evil_2_big_2.txt WA -
evil_2_big_3.txt WA -
evil_3_sorted_1.txt WA -
evil_4_sorted_rev_1.txt WA -
evil_4_sorted_rev_2.txt WA -
evil_400_sorted.txt WA -
evil_400_sorted_rev.txt WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import random

DEBUG = 1


class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)
        if n == 0:
            self.n0 = 0
        else:
            self.n0 = 1 << (n.bit_length() - 1)

    def sum_(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s

    def sum(self, l, r=-1):
        if r == -1:
            return self.sum_(l)
        else:
            return self.sum_(r) - self.sum_(l)

    def get(self, i):
        return self.sum(i, i + 1)

    def add(self, i, x):
        i += 1
        while i <= self.n:
            self.data[i] += x
            i += i & -i

    def lower_bound(self, x):
        if x <= 0:
            return 0
        i = 0
        k = self.n0
        while k > 0:
            if i + k <= self.n and self.data[i + k] < x:
                x -= self.data[i + k]
                i += k
            k //= 2
        return i + 1


n = int(input())
if DEBUG:
    ans = [i for i in range(1, n + 1)]
    random.shuffle(ans)

L = [0] * n
R = [i for i in range(n)]


def f():
    X = [(l + r) for l, r in zip(L, R)]
    for i in range(n - 1):
        if X[i] > i:
            X[i] -= i + 1
            X[i + 1] += 1

    for i in range(n - 1, 0, -1):
        if X[i] % 2 == 1:
            X[i - 1] += i
        X[i] //= 2
    X[0] //= 2
    return X


def ask(X, q="?"):
    P = []
    bit = BIT(n)
    for i in range(n):
        bit.add(i, 1)
    for x in X[::-1]:
        p = bit.lower_bound(x + 1) - 1
        P.append(p + 1)
        bit.add(p, -1)
    print(q, *P, flush=True)

    if DEBUG:
        for i in range(n):
            if P[i] < ans[i]:
                return 1
            elif P[i] > ans[i]:
                return 0
        return 1

    if len(set(P)) != n:
        return -1
    if q == "?":
        return int(input())
    else:
        assert ans == P


while 1:
    mid = f()
    if mid == L:
        break

    res = ask(mid)
    if res == -1:
        exit()
    if res == 0:
        R = mid
    else:
        L = mid

res = ask(R)
if res == -1:
    exit()
if res == 1:
    ask(R, "!")
else:
    ask(L, "!")
0