結果
問題 | No.2577 Simple Permutation Guess |
ユーザー | ecottea |
提出日時 | 2023-12-05 00:45:59 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 960 ms / 2,000 ms |
コード長 | 1,940 bytes |
コンパイル時間 | 441 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 93,896 KB |
平均クエリ数 | 248.84 |
最終ジャッジ日時 | 2024-09-26 23:48:26 |
合計ジャッジ時間 | 50,760 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 77 ms
69,600 KB |
testcase_01 | AC | 707 ms
93,408 KB |
testcase_02 | AC | 228 ms
93,836 KB |
testcase_03 | AC | 79 ms
75,992 KB |
testcase_04 | AC | 287 ms
93,664 KB |
testcase_05 | AC | 315 ms
93,408 KB |
testcase_06 | AC | 960 ms
93,628 KB |
testcase_07 | AC | 935 ms
93,280 KB |
testcase_08 | AC | 914 ms
93,536 KB |
testcase_09 | AC | 943 ms
93,664 KB |
testcase_10 | AC | 938 ms
93,664 KB |
testcase_11 | AC | 82 ms
76,768 KB |
testcase_12 | AC | 69 ms
68,952 KB |
testcase_13 | AC | 119 ms
88,664 KB |
testcase_14 | AC | 108 ms
82,144 KB |
testcase_15 | AC | 85 ms
76,128 KB |
testcase_16 | AC | 73 ms
69,472 KB |
testcase_17 | AC | 73 ms
68,448 KB |
testcase_18 | AC | 75 ms
68,832 KB |
testcase_19 | AC | 74 ms
69,216 KB |
testcase_20 | AC | 74 ms
68,960 KB |
testcase_21 | AC | 75 ms
68,704 KB |
testcase_22 | AC | 77 ms
69,464 KB |
testcase_23 | AC | 76 ms
68,568 KB |
testcase_24 | AC | 76 ms
68,568 KB |
testcase_25 | AC | 75 ms
68,952 KB |
testcase_26 | AC | 75 ms
69,200 KB |
testcase_27 | AC | 75 ms
68,824 KB |
testcase_28 | AC | 75 ms
69,208 KB |
testcase_29 | AC | 76 ms
69,208 KB |
testcase_30 | AC | 71 ms
69,080 KB |
testcase_31 | AC | 68 ms
69,472 KB |
testcase_32 | AC | 68 ms
68,960 KB |
testcase_33 | AC | 68 ms
68,832 KB |
testcase_34 | AC | 75 ms
69,216 KB |
testcase_35 | AC | 71 ms
69,088 KB |
testcase_36 | AC | 67 ms
69,088 KB |
testcase_37 | AC | 66 ms
68,960 KB |
testcase_38 | AC | 73 ms
68,824 KB |
testcase_39 | AC | 74 ms
69,208 KB |
testcase_40 | AC | 66 ms
68,600 KB |
testcase_41 | AC | 74 ms
69,088 KB |
testcase_42 | AC | 70 ms
69,088 KB |
testcase_43 | AC | 66 ms
69,088 KB |
testcase_44 | AC | 67 ms
69,080 KB |
testcase_45 | AC | 65 ms
68,696 KB |
testcase_46 | AC | 67 ms
68,992 KB |
testcase_47 | AC | 70 ms
69,088 KB |
testcase_48 | AC | 75 ms
68,960 KB |
testcase_49 | AC | 75 ms
68,952 KB |
testcase_50 | AC | 74 ms
69,080 KB |
testcase_51 | AC | 76 ms
68,952 KB |
testcase_52 | AC | 74 ms
68,568 KB |
testcase_53 | AC | 74 ms
68,824 KB |
testcase_54 | AC | 74 ms
68,824 KB |
testcase_55 | AC | 74 ms
69,336 KB |
testcase_56 | AC | 70 ms
68,440 KB |
testcase_57 | AC | 66 ms
69,592 KB |
testcase_58 | AC | 67 ms
68,952 KB |
testcase_59 | AC | 66 ms
68,952 KB |
testcase_60 | AC | 67 ms
68,952 KB |
testcase_61 | AC | 66 ms
68,952 KB |
testcase_62 | AC | 67 ms
68,824 KB |
testcase_63 | AC | 67 ms
68,952 KB |
testcase_64 | AC | 69 ms
68,440 KB |
testcase_65 | AC | 69 ms
68,696 KB |
testcase_66 | AC | 69 ms
68,952 KB |
testcase_67 | AC | 69 ms
69,720 KB |
testcase_68 | AC | 74 ms
69,080 KB |
testcase_69 | AC | 69 ms
69,336 KB |
testcase_70 | AC | 67 ms
68,952 KB |
testcase_71 | AC | 67 ms
68,952 KB |
testcase_72 | AC | 67 ms
68,992 KB |
testcase_73 | AC | 68 ms
68,832 KB |
testcase_74 | AC | 117 ms
86,240 KB |
testcase_75 | AC | 120 ms
86,880 KB |
testcase_76 | AC | 117 ms
86,880 KB |
testcase_77 | AC | 118 ms
86,368 KB |
testcase_78 | AC | 117 ms
86,112 KB |
testcase_79 | AC | 116 ms
86,496 KB |
testcase_80 | AC | 110 ms
86,880 KB |
testcase_81 | AC | 108 ms
86,112 KB |
testcase_82 | AC | 109 ms
86,880 KB |
testcase_83 | AC | 112 ms
87,136 KB |
testcase_84 | AC | 109 ms
85,984 KB |
testcase_85 | AC | 110 ms
86,880 KB |
testcase_86 | AC | 110 ms
86,624 KB |
testcase_87 | AC | 108 ms
86,984 KB |
testcase_88 | AC | 110 ms
86,728 KB |
testcase_89 | AC | 112 ms
86,600 KB |
testcase_90 | AC | 112 ms
87,112 KB |
testcase_91 | AC | 110 ms
86,984 KB |
testcase_92 | AC | 696 ms
93,128 KB |
testcase_93 | AC | 609 ms
93,384 KB |
testcase_94 | AC | 567 ms
93,384 KB |
testcase_95 | AC | 889 ms
93,896 KB |
testcase_96 | AC | 870 ms
93,768 KB |
testcase_97 | AC | 790 ms
93,768 KB |
testcase_98 | AC | 782 ms
93,380 KB |
testcase_99 | AC | 827 ms
93,512 KB |
testcase_100 | AC | 616 ms
93,512 KB |
testcase_101 | AC | 786 ms
93,896 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 | 923 ms
94,032 KB |
evil_4_sorted_rev_1.txt | AC | 984 ms
93,400 KB |
evil_4_sorted_rev_2.txt | AC | 1,638 ms
93,912 KB |
evil_400_sorted.txt | AC | 1,845 ms
94,928 KB |
evil_400_sorted_rev.txt | TLE | - |
ソースコード
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)