結果
問題 | No.1068 #いろいろな色 / Red and Blue and more various colors (Hard) |
ユーザー | tktk_snsn |
提出日時 | 2022-04-30 10:49:44 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,359 bytes |
コンパイル時間 | 484 ms |
コンパイル使用メモリ | 87,108 KB |
実行使用メモリ | 83,480 KB |
最終ジャッジ日時 | 2023-09-12 03:28:16 |
合計ジャッジ時間 | 9,962 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 69 ms
71,692 KB |
testcase_01 | AC | 68 ms
71,584 KB |
testcase_02 | AC | 75 ms
71,536 KB |
testcase_03 | AC | 305 ms
83,480 KB |
testcase_04 | AC | 246 ms
81,988 KB |
testcase_05 | AC | 263 ms
83,324 KB |
testcase_06 | AC | 229 ms
82,000 KB |
testcase_07 | AC | 224 ms
81,920 KB |
testcase_08 | AC | 254 ms
82,292 KB |
testcase_09 | AC | 266 ms
82,916 KB |
testcase_10 | AC | 180 ms
79,528 KB |
testcase_11 | AC | 223 ms
82,072 KB |
testcase_12 | AC | 172 ms
78,820 KB |
testcase_13 | TLE | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
ソースコード
""" ref https://atcoder.jp/contests/typical90/submissions/29013313 """ MOD = 998244353 RT = 3 def pr(n): return pow(RT, (MOD-1) // n, MOD) def inv(x): return pow(x, MOD-2, MOD) def FFT(a, w): N = len(a) if N == 1: return a even = a[::2] odd = a[1::2] ww = w * w % MOD EVEN = FFT(even, (ww) % MOD) ODD = FFT(odd, (ww) % MOD) A = [0] * N wk = 1 for k in range(N): A[k] = (EVEN[k % (N//2)] + wk * ODD[k % (N//2)] % MOD) % MOD wk = wk * w % MOD return A def convolution(a, b): d = len(a) + len(b) - 1 n = 1 while (1 << n) < d: n += 1 N = 1 << n w = pr(N) a += [0] * (N - len(a)) b += [0] * (N - len(b)) A = FFT(a, w) B = FFT(b, w) C = [A[i] * B[i] % MOD for i in range(N)] winv = inv(w) c = FFT(C, winv) invN = inv(N) for i in range(N): c[i] = c[i] * invN % MOD return c[:d] def main(): N, Q = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) que = [[a-1, 1] for a in A] while len(que) > 1: nque = [] while len(que) > 1: nque.append(convolution(que.pop(), que.pop())) if que: nque.append(que.pop()) que = nque F = que.pop() for b in B: print(F[b]) main()