結果

問題 No.1958 Bit Game
ユーザー hourenhouren
提出日時 2022-05-27 21:50:12
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 1,206 bytes
コンパイル時間 1,674 ms
コンパイル使用メモリ 171,356 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 20:08:16
合計ジャッジ時間 4,945 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
4,348 KB
testcase_01 AC 76 ms
4,348 KB
testcase_02 AC 76 ms
4,348 KB
testcase_03 AC 73 ms
4,348 KB
testcase_04 AC 75 ms
4,348 KB
testcase_05 AC 75 ms
4,348 KB
testcase_06 AC 76 ms
4,348 KB
testcase_07 AC 76 ms
4,348 KB
testcase_08 AC 75 ms
4,348 KB
testcase_09 AC 73 ms
4,348 KB
testcase_10 AC 18 ms
4,348 KB
testcase_11 AC 38 ms
4,348 KB
testcase_12 AC 46 ms
4,348 KB
testcase_13 AC 43 ms
4,348 KB
testcase_14 AC 37 ms
4,348 KB
testcase_15 AC 47 ms
4,348 KB
testcase_16 AC 31 ms
4,348 KB
testcase_17 AC 63 ms
4,348 KB
testcase_18 AC 61 ms
4,348 KB
testcase_19 AC 40 ms
4,348 KB
testcase_20 AC 44 ms
4,348 KB
testcase_21 AC 52 ms
4,348 KB
testcase_22 AC 22 ms
4,348 KB
testcase_23 AC 26 ms
4,348 KB
testcase_24 AC 55 ms
4,348 KB
testcase_25 AC 29 ms
4,348 KB
testcase_26 AC 42 ms
4,348 KB
testcase_27 AC 42 ms
4,348 KB
testcase_28 AC 51 ms
4,348 KB
testcase_29 AC 26 ms
4,348 KB
testcase_30 AC 1 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0