結果
問題 | No.2250 Split Permutation |
ユーザー | mkawa2 |
提出日時 | 2023-03-17 22:59:23 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 318 ms / 3,000 ms |
コード長 | 2,014 bytes |
コンパイル時間 | 160 ms |
コンパイル使用メモリ | 82,684 KB |
実行使用メモリ | 110,144 KB |
最終ジャッジ日時 | 2024-09-18 12:06:41 |
合計ジャッジ時間 | 5,984 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
53,480 KB |
testcase_01 | AC | 41 ms
53,260 KB |
testcase_02 | AC | 40 ms
52,688 KB |
testcase_03 | AC | 40 ms
54,416 KB |
testcase_04 | AC | 39 ms
53,604 KB |
testcase_05 | AC | 39 ms
54,072 KB |
testcase_06 | AC | 40 ms
52,748 KB |
testcase_07 | AC | 40 ms
52,740 KB |
testcase_08 | AC | 40 ms
53,020 KB |
testcase_09 | AC | 41 ms
53,880 KB |
testcase_10 | AC | 40 ms
53,356 KB |
testcase_11 | AC | 41 ms
53,428 KB |
testcase_12 | AC | 40 ms
53,568 KB |
testcase_13 | AC | 40 ms
53,220 KB |
testcase_14 | AC | 40 ms
53,768 KB |
testcase_15 | AC | 39 ms
53,580 KB |
testcase_16 | AC | 40 ms
54,220 KB |
testcase_17 | AC | 40 ms
52,408 KB |
testcase_18 | AC | 311 ms
110,144 KB |
testcase_19 | AC | 292 ms
105,932 KB |
testcase_20 | AC | 256 ms
102,444 KB |
testcase_21 | AC | 183 ms
93,064 KB |
testcase_22 | AC | 238 ms
101,404 KB |
testcase_23 | AC | 96 ms
80,052 KB |
testcase_24 | AC | 242 ms
101,476 KB |
testcase_25 | AC | 307 ms
109,804 KB |
testcase_26 | AC | 146 ms
88,564 KB |
testcase_27 | AC | 85 ms
78,008 KB |
testcase_28 | AC | 106 ms
81,600 KB |
testcase_29 | AC | 318 ms
109,948 KB |
testcase_30 | AC | 108 ms
82,256 KB |
testcase_31 | AC | 76 ms
76,860 KB |
testcase_32 | AC | 121 ms
84,196 KB |
testcase_33 | AC | 201 ms
95,872 KB |
testcase_34 | AC | 95 ms
79,792 KB |
testcase_35 | AC | 158 ms
88,852 KB |
testcase_36 | AC | 122 ms
83,388 KB |
testcase_37 | AC | 316 ms
109,928 KB |
ソースコード
import sys # sys.setrecursionlimit(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 << 63)-1 # inf = (1 << 31)-1 # md = 10**9+7 md = 998244353 class BitSum: def __init__(self, n): self._n = n+1 self._table = [0]*self._n self._origin = [0]*n def __getitem__(self, item): return self._origin[item] def add(self, i, x): self._origin[i] += x i += 1 while i < self._n: self._table[i] += x i += i & -i def sum(self, i): i += 1 res = 0 while i > 0: res += self._table[i] i -= i & -i return res def sumlr(self, l, r): if l >= r: return 0 if l == 0: return self.sum(r-1) return self.sum(r-1)-self.sum(l-1) # return "min(i) of sum(i)>=x" or "N" def bisect(self, x): idx = 0 d = 1 << (self._n-1).bit_length()-1 while d: if idx+d < self._n and self._table[idx+d] < x: x -= self._table[idx+d] idx |= d d >>= 1 return idx n = II() aa = LI1() pw = [1]*n for i in range(n-1): pw[i+1] = pw[i]*2%md ans = 0 bit = BitSum(n) for i in range(n)[::-1]: a = aa[i] ans += bit.sum(a)*pw[n-1]%md ans %= md bit.add(a, 1) bit = BitSum(n) for i in range(n)[::-1]: a = aa[i] ans -= bit.sum(a)*pw[i]%md ans %= md bit.add(a, pw[n-1-i]) print(ans)