結果
| 問題 |
No.1210 XOR Grid
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-30 16:21:34 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,212 bytes |
| コンパイル時間 | 1,125 ms |
| コンパイル使用メモリ | 83,064 KB |
| 実行使用メモリ | 6,784 KB |
| 最終ジャッジ日時 | 2024-11-15 11:04:08 |
| 合計ジャッジ時間 | 4,970 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 RE * 2 |
| other | AC * 27 RE * 30 |
ソースコード
#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 >>= 1, x *= x, ans %= MOD, x %= MOD)
if(n&1)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 {
exit(2);
cout<<power(2, (N-1) * (M-1) * X)<<endl;
}
return 0;
}