結果

問題 No.1958 Bit Game
ユーザー asaringoasaringo
提出日時 2022-05-27 22:42:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 483 ms / 2,000 ms
コード長 1,552 bytes
コンパイル時間 2,124 ms
コンパイル使用メモリ 207,312 KB
実行使用メモリ 19,348 KB
最終ジャッジ日時 2023-10-20 20:32:06
合計ジャッジ時間 13,629 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 465 ms
19,348 KB
testcase_01 AC 473 ms
19,348 KB
testcase_02 AC 481 ms
19,348 KB
testcase_03 AC 483 ms
19,348 KB
testcase_04 AC 470 ms
19,348 KB
testcase_05 AC 474 ms
19,348 KB
testcase_06 AC 466 ms
19,348 KB
testcase_07 AC 459 ms
19,348 KB
testcase_08 AC 462 ms
19,348 KB
testcase_09 AC 482 ms
19,348 KB
testcase_10 AC 148 ms
11,808 KB
testcase_11 AC 233 ms
11,612 KB
testcase_12 AC 226 ms
12,540 KB
testcase_13 AC 315 ms
15,808 KB
testcase_14 AC 294 ms
15,500 KB
testcase_15 AC 146 ms
9,636 KB
testcase_16 AC 84 ms
8,580 KB
testcase_17 AC 386 ms
16,984 KB
testcase_18 AC 314 ms
14,916 KB
testcase_19 AC 133 ms
9,900 KB
testcase_20 AC 404 ms
18,808 KB
testcase_21 AC 197 ms
11,240 KB
testcase_22 AC 227 ms
14,488 KB
testcase_23 AC 110 ms
9,900 KB
testcase_24 AC 408 ms
18,116 KB
testcase_25 AC 152 ms
11,228 KB
testcase_26 AC 368 ms
14,952 KB
testcase_27 AC 117 ms
8,844 KB
testcase_28 AC 389 ms
18,280 KB
testcase_29 AC 207 ms
10,980 KB
testcase_30 AC 2 ms
5,600 KB
testcase_31 AC 3 ms
5,600 KB
testcase_32 AC 3 ms
5,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std ;
#define fast_input_output ios::sync_with_stdio(false); cin.tie(nullptr);
typedef long long ll ;
typedef long double ld ;
typedef pair<ll,ll> P ;
typedef tuple<ll,ll,ll> TP ;
#define chmin(a,b) a = min(a,b)
#define chmax(a,b) a = max(a,b)
#define bit_count(x) __builtin_popcountll(x)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / gcd(a,b) * b
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define rrep(i,a,b) for(int i = a ; i < b ; i++)
#define endl "\n"

const int mod = 998244353 ;
ll powmod(ll x , ll n){
    ll res = 1 ;
    while(n > 0){
        if(n & 1) (res *= x) %= mod ;
        (x *= x) %= mod ;
        n >>= 1 ;
    }
    return res ;
}

ll n , x , y ;
ll A[404040] , B[404040] ;
vector<ll> bit_a(60,0) , bit_b(60,0) ;

int main(){
    fast_input_output
    cin >> n >> x >> y ;
    rep(i,x) cin >> A[i] ;
    rep(i,y) cin >> B[i] ;
    rep(i,x) rep(j,50) if(A[i] >> j & 1) bit_a[j]++ ;
    rep(i,y) rep(j,50) if(B[i] >> j & 1) bit_b[j]++ ;
    
    ll sum = 0 ;
    ll res = 0 ;

    rep(S,20){
        vector<vector<ll>> dp(n+1,vector<ll>(2,0)) ;
        dp[0][0] = 1 ;
        rep(i,n){
            (dp[i+1][1] += dp[i][0] * bit_a[S] % mod + dp[i][1] * x % mod) %= mod ;
            (dp[i+1][0] += (x - bit_a[S] + mod) % mod * dp[i][0] % mod) %= mod ;
            (dp[i+1][0] = (y - bit_b[S]) * dp[i+1][1] % mod + y * dp[i+1][0] % mod) %= mod ;
            (dp[i+1][1] *= bit_b[S]) %= mod ;
        }
        (res += (1 << S) * dp[n][1] % mod) %= mod ;
    }
    cout << res << endl ;
}
0