結果

問題 No.1142 XOR と XOR
ユーザー ゆきのんゆきのん
提出日時 2020-08-30 22:06:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 1,609 bytes
コンパイル時間 1,664 ms
コンパイル使用メモリ 167,516 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 16:42:57
合計ジャッジ時間 4,145 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,812 KB
testcase_01 AC 4 ms
6,940 KB
testcase_02 AC 4 ms
6,940 KB
testcase_03 AC 107 ms
6,940 KB
testcase_04 AC 72 ms
6,944 KB
testcase_05 AC 59 ms
6,940 KB
testcase_06 AC 73 ms
6,940 KB
testcase_07 AC 64 ms
6,940 KB
testcase_08 AC 89 ms
6,940 KB
testcase_09 AC 90 ms
6,940 KB
testcase_10 AC 89 ms
6,944 KB
testcase_11 AC 4 ms
6,944 KB
testcase_12 AC 4 ms
6,944 KB
testcase_13 AC 4 ms
6,940 KB
testcase_14 AC 49 ms
6,940 KB
testcase_15 AC 48 ms
6,944 KB
testcase_16 AC 7 ms
6,940 KB
testcase_17 AC 50 ms
6,944 KB
testcase_18 AC 15 ms
6,944 KB
testcase_19 AC 74 ms
6,944 KB
testcase_20 AC 49 ms
6,940 KB
testcase_21 AC 32 ms
6,944 KB
testcase_22 AC 20 ms
6,940 KB
testcase_23 AC 69 ms
6,940 KB
testcase_24 AC 78 ms
6,940 KB
testcase_25 AC 47 ms
6,944 KB
testcase_26 AC 75 ms
6,944 KB
testcase_27 AC 60 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};

 
int main(){
    int n,m,k;cin >> n >> m >> k;
    vector<int> a(n),b(m);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    vector<LL> ac(1<<11, 0), bc(1<<11, 0);
    int A = 0, B = 0;
    ac[0]++;
    for (int i = 0; i < n; i++) {
        A ^= a[i];
        ac[A]++;
    }
    bc[0]++;
    for (int i = 0; i < m; i++) {
        B ^= b[i];
        bc[B]++;
    }
    vector<LL> aa(1<<11, 0), bb(1<<11, 0);
    for (int i = 0; i < 1<<10; i++) {
        aa[i ^ i] = (aa[i ^ i] + ac[i] * (ac[i] - 1) / 2)%mod;
        bb[i ^ i] = (bb[i ^ i] + bc[i] * (bc[i] - 1) / 2)%mod;
        for (int j = i + 1; j < 1<<10; j++) {
            aa[i ^ j] = (aa[i ^ j] + ac[i] * ac[j]) %mod;
            bb[i ^ j] = (bb[i ^ j] + bc[i] * bc[j]) %mod;
        }
    }
    LL ans = 0;
    for (int i = 0; i < 1<<10; i++) {
        ans = (ans + aa[i] * bb[i ^ k])%mod;
    }
    cout << ans << endl;
    return 0;
}
0