結果
問題 | No.1958 Bit Game |
ユーザー |
![]() |
提出日時 | 2022-05-27 21:50:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 78 ms / 2,000 ms |
コード長 | 1,206 bytes |
コンパイル時間 | 1,836 ms |
コンパイル使用メモリ | 170,776 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-20 15:44:14 |
合計ジャッジ時間 | 4,840 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;using P = pair<ll,ll>;#define fix(x) fixed << setprecision(x)#define asc(x) x, vector<x>, greater<x>#define rep(i, n) for(ll i = 0; i < n; i++)#define all(x) (x).begin(),(x).end()template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}const ll MOD = 998244353;int main(){cin.tie(nullptr);ios::sync_with_stdio(false);ll n,x,y,ans=0;cin >> n >> x >> y;vector<ll> cnta(18,0), cntb(18,0), dp(18,0), dp2(18,0);rep(i,x){ll a;cin >> a;rep(j,18){cnta[j] += (a&1);a >>= 1;}}rep(i,y){ll a;cin >> a;rep(j,18){cntb[j] += (a&1);a >>= 1;}}ll tot = 1, t = x * y % MOD;rep(i,n){rep(j,18) dp2[j] = ((tot - dp[j]) * cnta[j] + dp[j] * x) % MOD;dp = dp2;rep(j,18) dp2[j] = dp[j] * cntb[j] % MOD;dp = dp2;tot = tot * t % MOD;}rep(i,18) ans = (ans + (1<<i)*dp[i]) % MOD;cout << (ans+MOD)%MOD << '\n';return 0;}