結果

問題 No.1142 XOR と XOR
ユーザー 沙耶花
提出日時 2020-07-31 21:49:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 991 bytes
コンパイル時間 2,163 ms
コンパイル使用メモリ 196,592 KB
最終ジャッジ日時 2025-01-12 09:47:13
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |                 scanf("%d",&a);
      |                 ~~~~~^~~~~~~~~
main.cpp:26:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   26 |                 scanf("%d",&b);
      |                 ~~~~~^~~~~~~~~

ソースコード

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