結果

問題 No.1870 Xor Matrix
ユーザー dekomori_sanaedekomori_sanae
提出日時 2022-03-12 10:06:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 1,652 bytes
コンパイル時間 1,050 ms
コンパイル使用メモリ 84,800 KB
実行使用メモリ 5,212 KB
最終ジャッジ日時 2023-10-14 21:57:42
合計ジャッジ時間 4,511 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 50 ms
4,488 KB
testcase_04 AC 80 ms
5,144 KB
testcase_05 AC 50 ms
4,348 KB
testcase_06 AC 57 ms
4,448 KB
testcase_07 AC 69 ms
4,588 KB
testcase_08 AC 69 ms
4,960 KB
testcase_09 AC 43 ms
4,376 KB
testcase_10 AC 60 ms
4,532 KB
testcase_11 AC 66 ms
4,600 KB
testcase_12 AC 69 ms
5,104 KB
testcase_13 AC 40 ms
4,348 KB
testcase_14 AC 78 ms
4,980 KB
testcase_15 AC 39 ms
4,348 KB
testcase_16 AC 47 ms
4,352 KB
testcase_17 AC 85 ms
5,212 KB
testcase_18 AC 61 ms
4,732 KB
testcase_19 AC 73 ms
5,012 KB
testcase_20 AC 53 ms
4,380 KB
testcase_21 AC 32 ms
4,372 KB
testcase_22 AC 49 ms
4,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 998244353;
const ll INF = 1e16;

// a^n (mod.MOD)を求める。計算量はO(logn)
ll modpow(ll a, ll n, ll MOD = mod) {
    if(n == 0) {
        return 1;
    }
    if(n % 2 == 1) {
        return a * modpow(a, n-1, MOD) % MOD;
    }
    return modpow(a, n/2, MOD) * modpow(a, n/2, MOD) % MOD;
}

int main() {
    ll n, m;
    cin >> n >> m;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    vl b(m);
    rep(i, m) {
        cin >> b[i];
    }

    ll ans = 1;
    rep(i, 20) {
        ll x = 0;
        rep(j, n) {
            if(a[j] & 1<<i) {
                x++;
            }
        }
        ll y = 0;
        rep(j, m) {
            if(b[j] & 1<<i) {
                y++;
            }
        }
        if(x % 2 == y % 2) {
            ans = ans * modpow(2LL, (n - 1) * (m - 1)) % mod;
        }
        else {
            ans = 0;
        }
    }
    
    out(ans);
    re0;
}
0