結果

問題 No.2577 Simple Permutation Guess
ユーザー ecotteaecottea
提出日時 2023-12-05 00:45:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 902 ms / 2,000 ms
コード長 1,940 bytes
コンパイル時間 527 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 92,976 KB
平均クエリ数 248.84
最終ジャッジ日時 2023-12-05 00:46:49
合計ジャッジ時間 46,803 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
69,468 KB
testcase_01 AC 641 ms
92,384 KB
testcase_02 AC 182 ms
92,356 KB
testcase_03 AC 65 ms
75,348 KB
testcase_04 AC 239 ms
92,640 KB
testcase_05 AC 288 ms
92,384 KB
testcase_06 AC 882 ms
92,560 KB
testcase_07 AC 874 ms
92,384 KB
testcase_08 AC 875 ms
92,384 KB
testcase_09 AC 902 ms
92,384 KB
testcase_10 AC 870 ms
92,384 KB
testcase_11 AC 68 ms
77,460 KB
testcase_12 AC 61 ms
69,468 KB
testcase_13 AC 98 ms
88,812 KB
testcase_14 AC 82 ms
82,000 KB
testcase_15 AC 67 ms
75,348 KB
testcase_16 AC 58 ms
69,468 KB
testcase_17 AC 58 ms
69,468 KB
testcase_18 AC 58 ms
69,468 KB
testcase_19 AC 58 ms
69,468 KB
testcase_20 AC 58 ms
69,468 KB
testcase_21 AC 60 ms
69,468 KB
testcase_22 AC 60 ms
69,460 KB
testcase_23 AC 60 ms
69,460 KB
testcase_24 AC 60 ms
69,460 KB
testcase_25 AC 63 ms
69,456 KB
testcase_26 AC 60 ms
69,460 KB
testcase_27 AC 60 ms
69,460 KB
testcase_28 AC 60 ms
69,460 KB
testcase_29 AC 63 ms
69,460 KB
testcase_30 AC 61 ms
69,460 KB
testcase_31 AC 61 ms
69,468 KB
testcase_32 AC 59 ms
69,468 KB
testcase_33 AC 60 ms
69,468 KB
testcase_34 AC 60 ms
69,468 KB
testcase_35 AC 60 ms
69,468 KB
testcase_36 AC 60 ms
69,468 KB
testcase_37 AC 85 ms
69,460 KB
testcase_38 AC 59 ms
69,460 KB
testcase_39 AC 62 ms
69,460 KB
testcase_40 AC 60 ms
69,460 KB
testcase_41 AC 60 ms
69,460 KB
testcase_42 AC 60 ms
69,456 KB
testcase_43 AC 60 ms
69,460 KB
testcase_44 AC 59 ms
69,460 KB
testcase_45 AC 59 ms
69,460 KB
testcase_46 AC 59 ms
69,460 KB
testcase_47 AC 59 ms
69,460 KB
testcase_48 AC 59 ms
69,460 KB
testcase_49 AC 65 ms
69,460 KB
testcase_50 AC 59 ms
69,460 KB
testcase_51 AC 59 ms
69,460 KB
testcase_52 AC 60 ms
69,460 KB
testcase_53 AC 60 ms
69,460 KB
testcase_54 AC 59 ms
69,460 KB
testcase_55 AC 60 ms
69,460 KB
testcase_56 AC 61 ms
69,460 KB
testcase_57 AC 59 ms
69,460 KB
testcase_58 AC 59 ms
69,460 KB
testcase_59 AC 59 ms
69,460 KB
testcase_60 AC 61 ms
69,460 KB
testcase_61 AC 61 ms
69,460 KB
testcase_62 AC 59 ms
69,460 KB
testcase_63 AC 59 ms
69,460 KB
testcase_64 AC 60 ms
69,460 KB
testcase_65 AC 60 ms
69,460 KB
testcase_66 AC 60 ms
69,460 KB
testcase_67 AC 60 ms
69,460 KB
testcase_68 AC 60 ms
69,460 KB
testcase_69 AC 59 ms
69,460 KB
testcase_70 AC 60 ms
69,460 KB
testcase_71 AC 60 ms
69,460 KB
testcase_72 AC 60 ms
69,460 KB
testcase_73 AC 59 ms
69,468 KB
testcase_74 AC 89 ms
86,700 KB
testcase_75 AC 93 ms
86,696 KB
testcase_76 AC 93 ms
86,696 KB
testcase_77 AC 91 ms
86,700 KB
testcase_78 AC 91 ms
86,700 KB
testcase_79 AC 91 ms
86,700 KB
testcase_80 AC 91 ms
86,700 KB
testcase_81 AC 93 ms
86,704 KB
testcase_82 AC 93 ms
86,704 KB
testcase_83 AC 95 ms
86,700 KB
testcase_84 AC 93 ms
86,704 KB
testcase_85 AC 92 ms
86,700 KB
testcase_86 AC 92 ms
86,704 KB
testcase_87 AC 93 ms
86,704 KB
testcase_88 AC 94 ms
86,704 KB
testcase_89 AC 92 ms
86,700 KB
testcase_90 AC 94 ms
86,704 KB
testcase_91 AC 92 ms
86,704 KB
testcase_92 AC 683 ms
92,388 KB
testcase_93 AC 572 ms
92,384 KB
testcase_94 AC 538 ms
92,384 KB
testcase_95 AC 840 ms
92,768 KB
testcase_96 AC 825 ms
92,384 KB
testcase_97 AC 795 ms
92,908 KB
testcase_98 AC 773 ms
92,976 KB
testcase_99 AC 792 ms
92,780 KB
testcase_100 AC 593 ms
92,384 KB
testcase_101 AC 751 ms
92,908 KB
evil_1_rnd_1.txt TLE -
evil_1_rnd_2.txt TLE -
evil_2_big_1.txt TLE -
evil_2_big_2.txt TLE -
evil_2_big_3.txt TLE -
evil_3_sorted_1.txt AC 882 ms
93,024 KB
evil_4_sorted_rev_1.txt AC 985 ms
92,516 KB
evil_4_sorted_rev_2.txt AC 1,572 ms
92,772 KB
evil_400_sorted.txt AC 1,777 ms
93,916 KB
evil_400_sorted_rev.txt TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
dump = lambda *x : print(*x, file = sys.stderr)

class FenwickTree:
    def __init__(self, n):
        self.n = n
        self.v = [0] * (n + 1)

    def __init__(self, a):
        self.n = len(a)
        self.v = [0] + a
        pow2 = 1
        while 2 * pow2 <= self.n:
            i = 2 * pow2
            while i <= self.n:
                self.v[i] += self.v[i - pow2]
                i += 2 * pow2
            pow2 *= 2

    def sum1(self, r):
        res = 0
        while r > 0:
            res += self.v[r]
            r -= r & -r
        return res
    
    def sum(self, l, r):
        return self.sum1(r) - self.sum1(l)

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

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

    def set(self, i, x):
        self.add(i, x - self.get(i))

    def max_right(self, dsi):
        x = 0
        l = 0

        len = 2**9
        while len > 0:
            r = l + len
            if r < self.n and x + self.v[r] <= dsi:
                x += self.v[r]
                l = r
            len //= 2

        return l
        
n = int(input())

ok = 0
ng = 1
for i in range(1, n + 1):
    ng *= i

while ng - ok >= 2:
    mid = (ok + ng) // 2
    #dump(ok, ng, mid)
    
    ds = [0] * n
    mid2 = mid
    for i in range(1, n + 1):
        ds[n - i] = mid2 % i
        mid2 //= i
    #dump(ds)
    
    p = [0] * n
    ft = FenwickTree([1] * n)
    for i in range(n):
        p[i] = ft.max_right(ds[i]) + 1
        ft.add(p[i] - 1, -1)
    #dump(p)

    print("? ", end="")
    print(*p)

    ret = int(input())

    if ret == 1:
        ok = mid
    else:
        ng = mid

ds = [0] * n
for i in range(1, n + 1):
    ds[n - i] = ok % i
    ok //= i
    
p = [0] * n
ft = FenwickTree([1] * n)
for i in range(n):
    p[i] = ft.max_right(ds[i]) + 1
    ft.add(p[i] - 1, -1)

print("! ", end="")
print(*p)
0