結果
問題 | No.1958 Bit Game |
ユーザー | startcpp |
提出日時 | 2022-05-28 02:53:20 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 969 bytes |
コンパイル時間 | 3,046 ms |
コンパイル使用メモリ | 143,676 KB |
実行使用メモリ | 26,920 KB |
最終ジャッジ日時 | 2023-10-20 22:31:07 |
合計ジャッジ時間 | 17,048 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | RE | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 202 ms
11,376 KB |
testcase_11 | AC | 340 ms
15,596 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 421 ms
19,240 KB |
testcase_15 | WA | - |
testcase_16 | AC | 96 ms
5,476 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 596 ms
25,992 KB |
testcase_21 | WA | - |
testcase_22 | AC | 332 ms
16,692 KB |
testcase_23 | AC | 153 ms
7,852 KB |
testcase_24 | WA | - |
testcase_25 | AC | 227 ms
10,580 KB |
testcase_26 | AC | 517 ms
22,960 KB |
testcase_27 | WA | - |
testcase_28 | AC | 594 ms
25,208 KB |
testcase_29 | AC | 320 ms
15,284 KB |
testcase_30 | AC | 2 ms
4,348 KB |
testcase_31 | AC | 2 ms
4,348 KB |
testcase_32 | AC | 3 ms
4,348 KB |
ソースコード
//ビットごとにできるので、はい。 #include <iostream> #include <atcoder/all> #include <vector> #define rep(i, n) for(i = 0; i < n; i++) using namespace std; using namespace atcoder; using mint = modint998244353; typedef vector<mint> Vec; typedef vector<Vec> Mat; int n, X, Y; int a[200000], b[200000]; int main() { int i, j; cin >> n >> X >> Y; rep(i, X) cin >> a[i]; rep(i, Y) cin >> b[i]; mint ans = 0; rep(i, 18) { int oneA = 0, oneB = 0; rep(j, X) if ((a[j] >> i) % 2) oneA++; rep(j, Y) if ((b[j] >> i) % 2) oneB++; Mat dp(2 * n + 1, Vec(2, 0)); dp[0][0] = 1; rep(j, 2 * n) { if (j % 2 == 0) { dp[j + 1][0] += (X - oneA) * dp[j][0]; dp[j + 1][1] += oneA * dp[j][0]; dp[j + 1][1] += X * dp[j][1]; } else { dp[j + 1][0] += Y * dp[j][0]; dp[j + 1][0] += (Y - oneB) * dp[j][1]; dp[j + 1][1] += oneB * dp[j][1]; } } ans += (1 << i) * dp[2 * n][1]; } cout << ans.val() << endl; return 0; }