結果
問題 | No.1856 Mex Sum 2 |
ユーザー | Mitarushi |
提出日時 | 2021-04-17 17:48:26 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,350 ms / 3,000 ms |
コード長 | 1,789 bytes |
コンパイル時間 | 403 ms |
コンパイル使用メモリ | 81,844 KB |
実行使用メモリ | 77,632 KB |
最終ジャッジ日時 | 2024-07-04 04:43:53 |
合計ジャッジ時間 | 40,095 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
52,828 KB |
testcase_01 | AC | 39 ms
54,044 KB |
testcase_02 | AC | 78 ms
76,400 KB |
testcase_03 | AC | 38 ms
52,988 KB |
testcase_04 | AC | 60 ms
66,636 KB |
testcase_05 | AC | 59 ms
66,648 KB |
testcase_06 | AC | 57 ms
65,660 KB |
testcase_07 | AC | 70 ms
73,504 KB |
testcase_08 | AC | 39 ms
52,896 KB |
testcase_09 | AC | 54 ms
65,288 KB |
testcase_10 | AC | 57 ms
65,924 KB |
testcase_11 | AC | 57 ms
65,132 KB |
testcase_12 | AC | 45 ms
60,204 KB |
testcase_13 | AC | 39 ms
52,996 KB |
testcase_14 | AC | 39 ms
53,616 KB |
testcase_15 | AC | 39 ms
53,716 KB |
testcase_16 | AC | 58 ms
66,284 KB |
testcase_17 | AC | 77 ms
76,020 KB |
testcase_18 | AC | 76 ms
76,496 KB |
testcase_19 | AC | 58 ms
65,708 KB |
testcase_20 | AC | 57 ms
65,516 KB |
testcase_21 | AC | 40 ms
55,288 KB |
testcase_22 | AC | 78 ms
76,068 KB |
testcase_23 | AC | 41 ms
54,996 KB |
testcase_24 | AC | 67 ms
71,384 KB |
testcase_25 | AC | 76 ms
76,280 KB |
testcase_26 | AC | 38 ms
53,492 KB |
testcase_27 | AC | 40 ms
52,832 KB |
testcase_28 | AC | 41 ms
53,928 KB |
testcase_29 | AC | 394 ms
77,112 KB |
testcase_30 | AC | 255 ms
76,760 KB |
testcase_31 | AC | 379 ms
77,116 KB |
testcase_32 | AC | 532 ms
77,080 KB |
testcase_33 | AC | 553 ms
77,116 KB |
testcase_34 | AC | 388 ms
77,132 KB |
testcase_35 | AC | 277 ms
76,912 KB |
testcase_36 | AC | 170 ms
76,744 KB |
testcase_37 | AC | 369 ms
77,012 KB |
testcase_38 | AC | 152 ms
77,000 KB |
testcase_39 | AC | 102 ms
77,116 KB |
testcase_40 | AC | 102 ms
77,008 KB |
testcase_41 | AC | 105 ms
76,724 KB |
testcase_42 | AC | 1,294 ms
77,268 KB |
testcase_43 | AC | 1,175 ms
77,384 KB |
testcase_44 | AC | 1,231 ms
77,384 KB |
testcase_45 | AC | 1,293 ms
77,364 KB |
testcase_46 | AC | 1,178 ms
77,484 KB |
testcase_47 | AC | 1,275 ms
77,128 KB |
testcase_48 | AC | 1,312 ms
77,240 KB |
testcase_49 | AC | 1,303 ms
76,872 KB |
testcase_50 | AC | 1,083 ms
76,996 KB |
testcase_51 | AC | 1,345 ms
77,384 KB |
testcase_52 | AC | 1,339 ms
77,080 KB |
testcase_53 | AC | 1,341 ms
77,240 KB |
testcase_54 | AC | 1,345 ms
77,632 KB |
testcase_55 | AC | 1,342 ms
77,124 KB |
testcase_56 | AC | 1,347 ms
77,128 KB |
testcase_57 | AC | 1,343 ms
77,240 KB |
testcase_58 | AC | 1,341 ms
77,044 KB |
testcase_59 | AC | 1,350 ms
77,248 KB |
testcase_60 | AC | 1,343 ms
77,012 KB |
testcase_61 | AC | 1,342 ms
77,016 KB |
testcase_62 | AC | 1,346 ms
77,372 KB |
testcase_63 | AC | 1,339 ms
77,124 KB |
testcase_64 | AC | 1,342 ms
77,600 KB |
testcase_65 | AC | 1,342 ms
77,260 KB |
testcase_66 | AC | 1,341 ms
77,264 KB |
ソースコード
mod = 998244353 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], a[k] = a[j]+a[k], (a[j]-a[k])*w[s*t] % mod 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 a[k] = a[k] * w[s*t] % mod a[j], a[k] = a[j]+a[k], a[j]-a[k] m <<= 1 t //= 2 n_inv = pow(n, mod-2, mod) for i in range(n): a[i] = a[i] * n_inv % mod n, m = map(int, input().split()) fixed_n = 1 << ((n+1)*2).bit_length() w_root = pow(3, (mod-1)//fixed_n, mod) w = [1] * fixed_n for i in range(1, fixed_n): w[i] = w[i-1] * w_root % mod frac = [1] * (n + 1) for i in range(1, n+1): frac[i] = frac[i-1] * i % mod frac_inv = [0] * (n+1) frac_inv[n] = pow(frac[n], mod-2, mod) for i in range(1, n+1)[::-1]: frac_inv[i-1] = frac_inv[i] * i % mod dp1 = [0] * fixed_n dp1[0] = 1 t = [0] * fixed_n for i in range(n+1): t[i] = (pow(2, i, mod)-1) * pow(pow(2, i, mod) * frac[i], mod-2, mod) % mod 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 % mod ifft_inplace(dp1, w) pow_tmp = 1 for i in range(k+1, n+1)[::-1]: ans_sub[i] += dp1[i] * pow_tmp % mod pow_tmp = pow_tmp * (m - k) % mod for i in range(n+1, fixed_n): dp1[i] = 0 ans = sum(ans_sub[i] % mod * frac_inv[n-i] for i in range(n+1)) % mod ans = ans * pow(2, n, mod) * frac[n] % mod print(ans)