結果

問題 No.1142 XOR と XOR
ユーザー 沙耶花沙耶花
提出日時 2020-07-31 21:49:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 991 bytes
コンパイル時間 2,236 ms
コンパイル使用メモリ 199,916 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 16:13:54
合計ジャッジ時間 3,759 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,816 KB
testcase_01 AC 5 ms
6,940 KB
testcase_02 AC 5 ms
6,944 KB
testcase_03 AC 44 ms
6,940 KB
testcase_04 AC 34 ms
6,940 KB
testcase_05 AC 29 ms
6,944 KB
testcase_06 AC 35 ms
6,944 KB
testcase_07 AC 37 ms
6,940 KB
testcase_08 AC 42 ms
6,940 KB
testcase_09 AC 42 ms
6,940 KB
testcase_10 AC 42 ms
6,944 KB
testcase_11 AC 6 ms
6,944 KB
testcase_12 AC 5 ms
6,944 KB
testcase_13 AC 5 ms
6,944 KB
testcase_14 AC 25 ms
6,940 KB
testcase_15 AC 24 ms
6,940 KB
testcase_16 AC 7 ms
6,940 KB
testcase_17 AC 29 ms
6,940 KB
testcase_18 AC 10 ms
6,944 KB
testcase_19 AC 34 ms
6,944 KB
testcase_20 AC 24 ms
6,944 KB
testcase_21 AC 16 ms
6,940 KB
testcase_22 AC 11 ms
6,940 KB
testcase_23 AC 32 ms
6,940 KB
testcase_24 AC 37 ms
6,940 KB
testcase_25 AC 23 ms
6,940 KB
testcase_26 AC 35 ms
6,944 KB
testcase_27 AC 28 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000002

int main(){

	int N,M,K;
	cin>>N>>M>>K;
	
	vector<int> ac(1024,0),bc(1024,0);
	ac[0]=1,bc[0]=1;
	
	int t = 0;
	for(int i=0;i<N;i++){
		int a;
		scanf("%d",&a);
		t^=a;
		ac[t]++;
	}
	
	t=0;
	for(int i=0;i<M;i++){
		int b;
		scanf("%d",&b);
		t^=b;
		bc[t]++;
	}
	{
		vector<int> temp(1024,0);
		for(int i=0;i<1024;i++){
			temp[0] = mod(temp[0] + mod(ac[i] * (ac[i]-1)/2));
			for(int j=i+1;j<1024;j++){
				temp[i^j] = mod(temp[i^j] + mod(ac[i]*ac[j]));
			}
		}
		ac = temp;
	}
	
	{
		vector<int> temp(1024,0);
		for(int i=0;i<1024;i++){
			temp[0] = mod(temp[0] + mod(bc[i] * (bc[i]-1)/2));
			for(int j=i+1;j<1024;j++){
				temp[i^j] = mod(temp[i^j] + mod(bc[i]*bc[j]));
			}
		}
		bc = temp;
	}
	
	int ans = 0;
	for(int i=0;i<1024;i++){
		int j = i^K;
		ans = mod(ans + mod(ac[i] * bc[j]));
	}
	
	cout<<ans<<endl;

	return 0;
}
0