結果

問題 No.1210 XOR Grid
ユーザー e869120e869120
提出日時 2021-02-26 09:06:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 511 ms / 2,000 ms
コード長 1,034 bytes
コンパイル時間 588 ms
コンパイル使用メモリ 65,628 KB
実行使用メモリ 7,244 KB
最終ジャッジ日時 2024-04-09 22:23:23
合計ジャッジ時間 12,618 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 259 ms
6,940 KB
testcase_26 AC 250 ms
6,944 KB
testcase_27 AC 247 ms
6,940 KB
testcase_28 AC 246 ms
6,944 KB
testcase_29 AC 250 ms
6,944 KB
testcase_30 AC 188 ms
6,944 KB
testcase_31 AC 249 ms
6,944 KB
testcase_32 AC 251 ms
6,944 KB
testcase_33 AC 2 ms
6,944 KB
testcase_34 AC 2 ms
6,940 KB
testcase_35 AC 2 ms
6,944 KB
testcase_36 AC 151 ms
6,944 KB
testcase_37 AC 141 ms
6,944 KB
testcase_38 AC 149 ms
6,940 KB
testcase_39 AC 91 ms
6,944 KB
testcase_40 AC 278 ms
7,244 KB
testcase_41 AC 288 ms
7,244 KB
testcase_42 AC 506 ms
7,244 KB
testcase_43 AC 418 ms
7,120 KB
testcase_44 AC 511 ms
7,240 KB
testcase_45 AC 506 ms
7,120 KB
testcase_46 AC 488 ms
6,988 KB
testcase_47 AC 62 ms
7,116 KB
testcase_48 AC 61 ms
7,116 KB
testcase_49 AC 2 ms
6,944 KB
testcase_50 AC 196 ms
7,240 KB
testcase_51 AC 493 ms
7,244 KB
testcase_52 AC 411 ms
6,984 KB
testcase_53 AC 481 ms
6,988 KB
testcase_54 AC 63 ms
7,120 KB
testcase_55 AC 392 ms
7,244 KB
testcase_56 AC 250 ms
6,944 KB
testcase_57 AC 240 ms
6,944 KB
testcase_58 AC 2 ms
6,944 KB
testcase_59 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

long long mod = 1000000007;
long long N, M, X;
long long A[1 << 18], B[1 << 18];

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 62; i++) {
		if ((b / (1LL << i)) % 2LL == 1) {
			p *= q; p %= m;
		}
		q *= q; q %= m;
	}
	return p;
}

int main() {
	// Step #1. 入力
	cin >> N >> M >> X;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 1; i <= M; i++) cin >> B[i];

	// Step #2. 計算
	long long Answer = 1;
	for (int i = 0; i < X; i++) {
		long long c0 = 0, c1 = 0, d0 = 0, d1 = 0;
		for (int j = 1; j <= N; j++) {
			if ((A[j] / (1LL << i)) % 2LL == 0) c0 += 1;
			if ((A[j] / (1LL << i)) % 2LL == 1) c1 += 1;
		}
		for (int j = 1; j <= M; j++) {
			if ((B[j] / (1LL << i)) % 2LL == 0) d0 += 1;
			if ((B[j] / (1LL << i)) % 2LL == 1) d1 += 1;
		}
		long long res = 0;
		if (c1 % 2LL == d1 % 2LL) {
			res = modpow(2LL, (N - 1) * (M - 1), mod);
		}
		Answer *= res;
		Answer %= mod;
	}
	cout << Answer << endl;
	return 0;
}
0