結果

問題 No.1958 Bit Game
ユーザー umimelumimel
提出日時 2022-05-27 22:07:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,406 ms / 2,000 ms
コード長 1,318 bytes
コンパイル時間 1,961 ms
コンパイル使用メモリ 170,836 KB
実行使用メモリ 7,464 KB
最終ジャッジ日時 2023-10-20 20:19:20
合計ジャッジ時間 31,641 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,406 ms
7,464 KB
testcase_01 AC 1,399 ms
7,464 KB
testcase_02 AC 1,377 ms
7,464 KB
testcase_03 AC 1,349 ms
7,464 KB
testcase_04 AC 1,344 ms
7,464 KB
testcase_05 AC 1,344 ms
7,464 KB
testcase_06 AC 1,342 ms
7,464 KB
testcase_07 AC 1,354 ms
7,464 KB
testcase_08 AC 1,342 ms
7,464 KB
testcase_09 AC 1,334 ms
7,464 KB
testcase_10 AC 403 ms
4,348 KB
testcase_11 AC 636 ms
5,088 KB
testcase_12 AC 539 ms
5,880 KB
testcase_13 AC 886 ms
5,352 KB
testcase_14 AC 836 ms
5,088 KB
testcase_15 AC 244 ms
6,408 KB
testcase_16 AC 125 ms
5,352 KB
testcase_17 AC 1,075 ms
6,672 KB
testcase_18 AC 812 ms
6,672 KB
testcase_19 AC 252 ms
5,616 KB
testcase_20 AC 1,231 ms
5,088 KB
testcase_21 AC 387 ms
6,408 KB
testcase_22 AC 683 ms
4,348 KB
testcase_23 AC 231 ms
4,824 KB
testcase_24 AC 1,176 ms
6,144 KB
testcase_25 AC 363 ms
4,824 KB
testcase_26 AC 1,047 ms
5,088 KB
testcase_27 AC 172 ms
6,144 KB
testcase_28 AC 1,173 ms
5,616 KB
testcase_29 AC 603 ms
4,348 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
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second

const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll INF = 1LL << 60;
const ll N_MAX = 2e5;

ll pow_mod(ll x, ll n, ll mod){
    ll ret = 1;
    while(n > 0){
        if(n & 1) ret = (ret*x)%mod;
        x = x*x%mod;
        n >>=1;
    }
    return ret;
}

int main(){
    ll n, x, y;
    cin >> n >> x >> y;

    vector<ll> a(x), b(y);
    rep(i, x) cin >> a[i];
    rep(j, y) cin >> b[j];

    ll ans = 0;
    for(ll i=0; i<=18; i++){
        ll a_cnt = 0;
        ll b_cnt = 0;
        rep(j, x) if((a[j]>>i) & 1) a_cnt++;
        rep(j, y) if((b[j]>>i) & 1) b_cnt++;

        ll sa = 0;
        for(ll j=n; j>=1; j--){
            ll pre = (pow_mod(x, j-1, MOD2)*pow_mod(y, j-1, MOD2))%MOD2;
            ll mid = (a_cnt*b_cnt)%MOD2;
            ll pos = (pow_mod(x-a_cnt, n-j, MOD2)*pow_mod(b_cnt, n-j, MOD2))%MOD2;
            ll tmp = (pre*mid)%MOD2;
            sa += (tmp*pos)%MOD2;
            sa %= MOD2;
        }

        ans += (sa*pow_mod(2, i, MOD2))%MOD2;
        ans %= MOD2;
    }

    cout << ans << endl;
}
0