結果
| 問題 |
No.1958 Bit Game
|
| コンテスト | |
| ユーザー |
8nd5t
|
| 提出日時 | 2022-05-28 05:34:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,901 bytes |
| コンパイル時間 | 240 ms |
| コンパイル使用メモリ | 82,148 KB |
| 実行使用メモリ | 168,960 KB |
| 最終ジャッジ日時 | 2024-09-20 20:32:18 |
| 合計ジャッジ時間 | 7,579 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 29 |
ソースコード
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right
import sys,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_1(): return list(map(lambda x:int(x)-1, sys.stdin.readline().split()))
def err(x): print(x); exit()
class Combination:
"""
comb = Combination(1000000)
print(comb(5, 3)) # 10
"""
def __init__(self, n_max, mod=10**9+7):
self.mod = mod
self.modinv = self.make_modinv_list(n_max)
self.fac, self.facinv = self.make_factorial_list(n_max)
def __call__(self, n, r):
return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod
def make_factorial_list(self, n):
fac = [1]
facinv = [1]
for i in range(1, n+1):
fac.append(fac[i-1] * i % self.mod)
facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
return fac, facinv
def make_modinv_list(self, n):
# 0からnまでのmod逆元のリストを返す O(n)
modinv = [0] * (n+1)
modinv[1] = 1
for i in range(2, n+1):
modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
return modinv
mod = 998244353
m = 18
n,x,y = inpl()
a = inpl()
b = inpl()
res = 0
p = [1]
for i in range(n):
p.append(p[-1]*x*y%mod)
for d in range(m):
cnta = cntb = 0
ans = 0
for aa in a:
if (aa>>d)%2:
cnta += 1
for bb in b:
if (bb>>d)%2:
cntb += 1
if cnta == 0 or cntb == 0:
continue
for i in range(n):
ans += p[i]*cnta%mod*pow(cntb,n-i,mod)%mod*pow(x-cnta,n-i-1,mod)
ans %= mod
res += ans*pow(2,d,mod)
res %= mod
print(res)
8nd5t