結果

問題 No.1210 XOR Grid
ユーザー tnakao0123
提出日時 2020-08-31 12:02:01
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 1,318 bytes
コンパイル時間 746 ms
コンパイル使用メモリ 94,220 KB
実行使用メモリ 6,860 KB
最終ジャッジ日時 2024-11-15 19:26:21
合計ジャッジ時間 6,209 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 57
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1210.cc:  No.1210 XOR Grid - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int MAX_X = 60;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

ll as[MAX_N], bs[MAX_N];
int acs[2], bcs[2];

/* subroutines */

int powmod(int a, int n) {  // a^n % MOD
  int pm = 1;
  while (n > 0) {
    if (n & 1) pm = (ll)pm * a % MOD;
    a = (ll)a * a % MOD;
    n >>= 1;
  }
  return pm;
}

/* main */

int main() {
  int h, w, x;
  scanf("%d%d%d", &h, &w, &x);
  for (int i = 0; i < h; i++) scanf("%lld", as + i);
  for (int i = 0; i < w; i++) scanf("%lld", bs + i);

  ll xa = 0, xb = 0;
  for (int i = 0; i < h; i++) xa ^= as[i];
  for (int i = 0; i < w; i++) xb ^= bs[i];
  
  if (xa == xb) {
    int hwx = (ll)(h - 1) * (w - 1) % (MOD - 1) * x % (MOD - 1);
    printf("%d\n", powmod(2, hwx));
  }
  else
    puts("0");

  return 0;
}
0