結果
問題 | No.1856 Mex Sum 2 |
ユーザー | Mitarushi |
提出日時 | 2021-04-17 17:53:10 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,326 ms / 3,000 ms |
コード長 | 1,928 bytes |
コンパイル時間 | 232 ms |
コンパイル使用メモリ | 82,292 KB |
実行使用メモリ | 77,316 KB |
最終ジャッジ日時 | 2024-07-04 04:46:43 |
合計ジャッジ時間 | 38,239 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
53,688 KB |
testcase_01 | AC | 37 ms
52,524 KB |
testcase_02 | AC | 74 ms
75,976 KB |
testcase_03 | AC | 38 ms
53,088 KB |
testcase_04 | AC | 55 ms
65,184 KB |
testcase_05 | AC | 57 ms
66,348 KB |
testcase_06 | AC | 55 ms
66,648 KB |
testcase_07 | AC | 70 ms
72,372 KB |
testcase_08 | AC | 38 ms
53,492 KB |
testcase_09 | AC | 50 ms
63,792 KB |
testcase_10 | AC | 55 ms
65,252 KB |
testcase_11 | AC | 54 ms
65,868 KB |
testcase_12 | AC | 42 ms
60,036 KB |
testcase_13 | AC | 37 ms
52,336 KB |
testcase_14 | AC | 36 ms
53,492 KB |
testcase_15 | AC | 37 ms
53,212 KB |
testcase_16 | AC | 54 ms
66,304 KB |
testcase_17 | AC | 69 ms
76,416 KB |
testcase_18 | AC | 66 ms
74,384 KB |
testcase_19 | AC | 54 ms
66,732 KB |
testcase_20 | AC | 55 ms
66,532 KB |
testcase_21 | AC | 38 ms
53,792 KB |
testcase_22 | AC | 71 ms
75,984 KB |
testcase_23 | AC | 38 ms
53,688 KB |
testcase_24 | AC | 63 ms
71,204 KB |
testcase_25 | AC | 70 ms
76,264 KB |
testcase_26 | AC | 36 ms
52,456 KB |
testcase_27 | AC | 37 ms
53,084 KB |
testcase_28 | AC | 39 ms
53,332 KB |
testcase_29 | AC | 380 ms
77,024 KB |
testcase_30 | AC | 242 ms
76,800 KB |
testcase_31 | AC | 356 ms
77,176 KB |
testcase_32 | AC | 506 ms
76,916 KB |
testcase_33 | AC | 530 ms
77,060 KB |
testcase_34 | AC | 369 ms
77,032 KB |
testcase_35 | AC | 269 ms
77,276 KB |
testcase_36 | AC | 166 ms
76,536 KB |
testcase_37 | AC | 355 ms
77,312 KB |
testcase_38 | AC | 150 ms
76,908 KB |
testcase_39 | AC | 95 ms
76,532 KB |
testcase_40 | AC | 98 ms
76,680 KB |
testcase_41 | AC | 98 ms
76,684 KB |
testcase_42 | AC | 1,265 ms
77,304 KB |
testcase_43 | AC | 1,118 ms
76,920 KB |
testcase_44 | AC | 1,186 ms
77,060 KB |
testcase_45 | AC | 1,254 ms
77,032 KB |
testcase_46 | AC | 1,128 ms
76,932 KB |
testcase_47 | AC | 1,171 ms
77,168 KB |
testcase_48 | AC | 1,257 ms
77,056 KB |
testcase_49 | AC | 1,236 ms
76,924 KB |
testcase_50 | AC | 1,043 ms
77,152 KB |
testcase_51 | AC | 1,297 ms
77,160 KB |
testcase_52 | AC | 1,287 ms
77,312 KB |
testcase_53 | AC | 1,292 ms
77,036 KB |
testcase_54 | AC | 1,288 ms
76,908 KB |
testcase_55 | AC | 1,285 ms
77,064 KB |
testcase_56 | AC | 1,287 ms
77,192 KB |
testcase_57 | AC | 1,292 ms
77,316 KB |
testcase_58 | AC | 1,289 ms
76,780 KB |
testcase_59 | AC | 1,271 ms
76,856 KB |
testcase_60 | AC | 1,288 ms
76,804 KB |
testcase_61 | AC | 1,290 ms
77,056 KB |
testcase_62 | AC | 1,299 ms
76,932 KB |
testcase_63 | AC | 1,295 ms
77,032 KB |
testcase_64 | AC | 1,326 ms
77,292 KB |
testcase_65 | AC | 1,287 ms
77,316 KB |
testcase_66 | AC | 1,274 ms
76,924 KB |
ソースコード
def fft_inplace(a, w): n = len(a) m = n t = 1 while m >= 2: mh = m >> 1 for i in range(0, n, m): for s in range(mh): j, k = i+s, i+mh+s a[j], u = a[j]+a[k], a[j]-a[k] a[k] = u * w[s*t] % 998244353 m = mh t *= 2 def ifft_inplace(a, w): n = len(a) m = 2 t = -(n >> 1) while m <= n: mh = m >> 1 for i in range(0, n, m): for s in range(mh): j, k = i+s, i+mh+s u = a[k] * w[s*t] % 998244353 a[j], a[k] = a[j]+u, a[j]-u m <<= 1 t //= 2 n_inv = pow(n, 998244353-2, 998244353) for i in range(n): a[i] = a[i] * n_inv % 998244353 n, m = map(int, input().split()) fixed_n = 1 << ((n+1)*2).bit_length() w_root = pow(3, (998244353-1)//fixed_n, 998244353) w = [1] * fixed_n for i in range(1, fixed_n): w[i] = w[i-1] * w_root % 998244353 frac = [1] * (n + 1) for i in range(1, n+1): frac[i] = frac[i-1] * i % 998244353 frac_inv = [0] * (n+1) frac_inv[n] = pow(frac[n], 998244353-2, 998244353) for i in range(1, n+1)[::-1]: frac_inv[i-1] = frac_inv[i] * i % 998244353 dp1 = [0] * fixed_n dp1[0] = 1 t = [0] * fixed_n for i in range(n+1): t[i] = (pow(2, i, 998244353)-1) * pow(pow(2, i, 998244353) * frac[i], 998244353-2, 998244353) % 998244353 fft_inplace(t, w) ans_sub = [0] * (n+1) for k in range(min(n, m+1)): fft_inplace(dp1, w) for i, j in enumerate(t): dp1[i] = dp1[i] * j % 998244353 ifft_inplace(dp1, w) pow_tmp = 1 for i in range(k+1, n+1)[::-1]: ans_sub[i] += dp1[i] * pow_tmp % 998244353 pow_tmp = pow_tmp * (m - k) % 998244353 for i in range(n+1, fixed_n): dp1[i] = 0 ans = sum(ans_sub[i] % 998244353 * frac_inv[n-i] for i in range(n+1)) % 998244353 ans = ans * pow(2, n, 998244353) * frac[n] % 998244353 print(ans)