結果
| 問題 | No.1210 XOR Grid | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-08-30 16:52:20 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 73 ms / 2,000 ms | 
| コード長 | 1,393 bytes | 
| コンパイル時間 | 1,563 ms | 
| コンパイル使用メモリ | 83,448 KB | 
| 実行使用メモリ | 6,528 KB | 
| 最終ジャッジ日時 | 2024-11-15 11:35:07 | 
| 合計ジャッジ時間 | 5,136 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 57 | 
ソースコード
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
#define int long long
#define endl "\n"
constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 
struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;
long long power(long long x, long long n){
	long long ans = 1;
	for(;n;n >>= 1ll, x *= x, ans %= MOD, x %= MOD)
		if(n&1ll)ans*=x;
	return ans % MOD;
}
	
signed main(){
	cout<<fixed<<setprecision(10);
	
	
	
	int N, M, X;
	vector<int> A, B;
	
	cin>>N>>M>>X;
	
	A.resize(N);
	B.resize(M);
	
	
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
	}
	
	for(int j = 0; j < M; j++){
		cin>>B[j];
	}
	
	if(N == 1 && M == 1) {
		if(A[0] == B[0]) cout<<1<<endl;
		else cout<<0<<endl;
	} else if(N == 1) {
		int XOR = 0;
		
		for(int i = 0; i < M; i++){
			XOR ^= B[i];
		}
		
		if(XOR == A[0]) cout<<1<<endl;
		else cout<<0<<endl;
		
	} else if(M == 1){
		int XOR = 0;
		
		for(int i = 0; i < N; i++){
			XOR ^= A[i];
		}
		
		if(XOR == B[0]) cout<<1<<endl;
		else cout<<0<<endl;
	} else {
		int XORA = 0;
		
		for(int i = 0; i < N; i++){
			XORA ^= A[i];
		}
		int XORB = 0;
		
		for(int i = 0; i < M; i++){
			XORB ^= B[i];
		}
		if(XORB == XORA)cout<<power(2, (N-1) * (M-1) * X) % MOD<<endl;
		else cout<<0<<endl;
	}
	return 0;
}
            
            
            
        