結果
| 問題 |
No.1958 Bit Game
|
| コンテスト | |
| ユーザー |
tute7627
|
| 提出日時 | 2022-05-21 02:09:37 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 273 ms / 2,000 ms |
| コード長 | 969 bytes |
| コンパイル時間 | 2,109 ms |
| コンパイル使用メモリ | 197,932 KB |
| 最終ジャッジ日時 | 2025-01-29 12:31:03 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include<bits/stdc++.h>
#include<atcoder/modint>
using namespace std;
int main(){
int N, X, Y;
cin >> N >> X >> Y;
assert(1 <= N && N <= (int)2e5);
assert(1 <= X && X <= 1<<18);
assert(1 <= Y && Y <= 1<<18);
vector<int> A(X), B(Y);
for(int i = 0; i < X; i++){
cin >> A[i];
assert(0 <= A[i] && A[i] < 1<<18);
}
for(int i = 0; i < Y; i++){
cin >> B[i];
assert(0 <= B[i] && B[i] < 1<<18);
}
atcoder::modint998244353 ans = 0;
for(int i = 0; i < 18; i++){
atcoder::modint998244353 x0 = 0, x1 = 0, y0 = 0, y1 = 0;
for(int j = 0; j < X; j++){
if(A[j] >> i & 1)x1 += 1;
else x0 += 1;
}
for(int j = 0; j < Y; j++){
if(B[j] >> i & 1)y1 += 1;
else y0 += 1;
}
atcoder::modint998244353 p0 = 1, p1 = 0;
for(int j = 0; j < N; j++){
p1 = p1 * X + p0 * x1;
p0 *= x0;
p0 = p0 * Y + p1 * y0;
p1 *= y1;
}
ans += p1 * (1 << i);
}
cout << ans.val() << endl;
}
tute7627