結果
問題 |
No.1503 Bitwise And Convolution Twisted
|
ユーザー |
|
提出日時 | 2021-05-07 22:35:52 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,310 bytes |
コンパイル時間 | 244 ms |
コンパイル使用メモリ | 82,184 KB |
実行使用メモリ | 600,480 KB |
最終ジャッジ日時 | 2024-09-15 10:41:26 |
合計ジャッジ時間 | 6,515 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 MLE * 1 -- * 2 |
ソースコード
mod = 998244353 def subset(n,X): res = [[] for i in range(2*n)] for i in range(n,2*n): res[i] = [X[i-n]] for i in range(n-1,-1,-1): res[i] = res[2*i] + res[2*i+1] size = len(res[i])//2 for j in range(size): res[i][j+size] += res[i][j] res[i][j+size] %= mod return res[1] def isubset(n,X): res = [[] for i in range(2 * n)] for i in range(n,2*n): res[i] = [X[i-n]] for i in range(n-1,-1,-1): res[i] = res[2*i] + res[2*i+1] size = len(res[i])//2 for j in range(size): res[i][j+size] -= res[i][j] res[i][j+size] %= mod return res[1] import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import log,gcd input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) N = int(input()) A = li() B = li() A = A[::-1] A1 = subset(1<<N,A) A1 = A1[::-1] B1 = isubset(1<<N,B) C = [A1[k]*B1[k]%mod for k in range(1<<N)] C = subset(1<<N,C) print(*C) """ C_n = \sum_{i subset n} B_i (\sum_{i subset j subset n} (-1)**(j-i) A1_j) = \sum_{i subset n} \sum_{j subset i} A1_i * (i-j) * B_j = \sum_{i subset n} A1_i B1_i """