結果

問題 No.1958 Bit Game
ユーザー k1suxuk1suxu
提出日時 2022-05-27 23:18:30
言語 C++23(draft)
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,293 ms / 2,000 ms
コード長 3,012 bytes
コンパイル時間 4,068 ms
コンパイル使用メモリ 253,760 KB
実行使用メモリ 10,372 KB
最終ジャッジ日時 2023-10-20 20:43:35
合計ジャッジ時間 30,963 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,262 ms
10,372 KB
testcase_01 AC 1,266 ms
10,372 KB
testcase_02 AC 1,255 ms
10,372 KB
testcase_03 AC 1,272 ms
10,372 KB
testcase_04 AC 1,293 ms
10,372 KB
testcase_05 AC 1,248 ms
10,372 KB
testcase_06 AC 1,246 ms
10,372 KB
testcase_07 AC 1,248 ms
10,372 KB
testcase_08 AC 1,253 ms
10,372 KB
testcase_09 AC 1,269 ms
10,372 KB
testcase_10 AC 410 ms
7,204 KB
testcase_11 AC 620 ms
8,260 KB
testcase_12 AC 515 ms
9,052 KB
testcase_13 AC 839 ms
8,524 KB
testcase_14 AC 790 ms
8,260 KB
testcase_15 AC 220 ms
9,580 KB
testcase_16 AC 124 ms
8,524 KB
testcase_17 AC 989 ms
9,844 KB
testcase_18 AC 750 ms
9,844 KB
testcase_19 AC 261 ms
8,788 KB
testcase_20 AC 1,173 ms
8,260 KB
testcase_21 AC 355 ms
9,580 KB
testcase_22 AC 672 ms
7,204 KB
testcase_23 AC 219 ms
7,996 KB
testcase_24 AC 1,111 ms
9,316 KB
testcase_25 AC 355 ms
7,996 KB
testcase_26 AC 1,009 ms
8,260 KB
testcase_27 AC 167 ms
9,052 KB
testcase_28 AC 1,119 ms
8,788 KB
testcase_29 AC 593 ms
7,468 KB
testcase_30 AC 30 ms
6,412 KB
testcase_31 AC 30 ms
6,412 KB
testcase_32 AC 32 ms
6,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i = (int)a; i < (int)b; i++)
#define pb push_back
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
//#define mp make_pair
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vvll vector<vll>
#define vs vector<string>
#define vvs vector<vs>
#define vc vector<char>
#define vvc vector<vc>
#define pii pair<int,int>
#define pllll pair<ll,ll>
#define vpii vector<pair<int,int>>
#define vpllll vector<pair<ll,ll>>
#define vpis vector<pair<int,string>>
#define vplls vector<pair<ll, string>>
#define vpsi vector<pair<string, int>>
#define vpsll vector<pair<string, ll>>

template<typename T>
void chmax(T &a, const T &b) {a = (a > b? a : b);}
template<typename T>
void chmin(T &a, const T &b) {a = (a < b? a : b);}

using ll = long long;
using ld = long double;
using ull = unsigned long long;

const ll INF = numeric_limits<long long>::max() / 10;
const ld pi = acos(-1);
const ll mod = 998244353;
int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1};
int dy[] = {0, -1, 0, 1, -1, 1, -1, 1};

#define int long long

vector<int> f, rf;
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
void init(int n) {
    f.resize(n, 0);
    rf.resize(n, 0);
    f[0] = 1;
    repi(i, 1, n) f[i] = (f[i - 1] * i) % mod;
    repi(i, 0, n) rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
ll P(int n, int k) {
    ll a = f[n];
    ll b = rf[n - k];
    return a * b % mod;
}

ll C(int n, int k) {
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % mod;

    return (a * bc) % mod;
}

ll H(int n, int k) {
    return C(n + k - 1, k);
}

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

void solve() {
    init(200100);
    int n, x, y;
    cin >> n >> x >> y;
    vi a(x), b(y);
    FOR(x) cin >> a[i];
    FOR(y) cin >> b[i];

    vi ca(18, 0);
    for(auto e : a) {
        rep(j, 18) {
            if(e >> j & 1) ca[j]++;
        }
    }
    vi cb(18, 0);
    for(auto e : b) {
        rep(j, 18) {
            if(e >> j & 1) cb[j]++;
        }
    }

    int ans = 0;
    rep(i, 18) {
        for(int j = n; j >= 1; j--) {
            ans += (1LL<<i) * powmod(y, j-1) % mod * powmod(cb[i], n-j+1) % mod * powmod(x-ca[i], n-j) % mod * ca[i] % mod * powmod(x, j-1) % mod;
            ans %= mod;
        }
    }

    cout << (ans % mod + mod) % mod << endl;
}

//abc102 Equal Cut

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}
0