結果

問題 No.1142 XOR と XOR
ユーザー chocoruskchocorusk
提出日時 2020-07-31 21:40:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 1,590 bytes
コンパイル時間 1,420 ms
コンパイル使用メモリ 126,888 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-25 16:12:32
合計ジャッジ時間 3,947 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,820 KB
testcase_01 AC 4 ms
6,940 KB
testcase_02 AC 4 ms
6,940 KB
testcase_03 AC 106 ms
6,944 KB
testcase_04 AC 71 ms
6,940 KB
testcase_05 AC 59 ms
6,944 KB
testcase_06 AC 73 ms
6,944 KB
testcase_07 AC 63 ms
6,944 KB
testcase_08 AC 90 ms
6,940 KB
testcase_09 AC 89 ms
6,940 KB
testcase_10 AC 88 ms
6,940 KB
testcase_11 AC 4 ms
6,940 KB
testcase_12 AC 4 ms
6,944 KB
testcase_13 AC 4 ms
6,948 KB
testcase_14 AC 50 ms
6,940 KB
testcase_15 AC 48 ms
6,940 KB
testcase_16 AC 8 ms
6,944 KB
testcase_17 AC 50 ms
6,940 KB
testcase_18 AC 14 ms
6,944 KB
testcase_19 AC 73 ms
6,940 KB
testcase_20 AC 47 ms
6,944 KB
testcase_21 AC 32 ms
6,944 KB
testcase_22 AC 19 ms
6,944 KB
testcase_23 AC 67 ms
6,940 KB
testcase_24 AC 76 ms
6,944 KB
testcase_25 AC 46 ms
6,940 KB
testcase_26 AC 72 ms
6,944 KB
testcase_27 AC 59 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
int sa[200020], sb[200020];
ll cnta[1<<10], cntb[1<<10];
ll cnt1[1<<10], cnt2[1<<10];
int main()
{
	int n, m, k; cin>>n>>m>>k;
	for(int i=0; i<n; i++){
		int a; cin>>a;
		sa[i+1]=(sa[i]^a);
	}
	for(int i=0; i<m; i++){
		int b; cin>>b;
		sb[i+1]=(sb[i]^b);
	}
	for(int i=0; i<=n; i++){
		cnta[sa[i]]++;
	}
	for(int i=0; i<=m; i++){
		cntb[sb[i]]++;
	}
	for(int i=0; i<1024; i++){
		for(int j=0; j<1024; j++){
			cnt1[i^j]+=cnta[i]*cnta[j];
		}
	}
	cnt1[0]-=n;
	for(int i=0; i<1024; i++){
		cnt1[i]=cnt1[i]/2%MOD;
	}
	for(int i=0; i<1024; i++){
		for(int j=0; j<1024; j++){
			cnt2[i^j]+=cntb[i]*cntb[j];
		}
	}
	cnt2[0]-=m;
	for(int i=0; i<1024; i++){
		cnt2[i]=cnt2[i]/2%MOD;
	}
	ll ans=0;
	for(int i=0; i<1024; i++){
		(ans+=cnt1[i]*cnt2[i^k])%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}
0