結果

問題 No.1210 XOR Grid
ユーザー nebukuro09nebukuro09
提出日時 2020-08-30 14:29:09
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 856 bytes
コンパイル時間 794 ms
コンパイル使用メモリ 129,024 KB
実行使用メモリ 27,800 KB
最終ジャッジ日時 2024-06-22 08:46:59
合計ジャッジ時間 5,592 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 57
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdlib, std.datetime;

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto H = s[0];
    auto W = s[1];
    auto X = s[2];

    auto A = readln.split.map!(to!long).array;
    auto B = readln.split.map!(to!long).array;

    long x = 0;
    foreach (a; A) x ^= a;
    foreach (b; B) x ^= b;

    if (x != 0) {
        writeln(0);
        return;
    }

    long ans = powmod(2, 1L*(H-1)*(W-1), MOD);
    ans = powmod(ans, X, MOD);

    ans.writeln;
}

long powmod(long a, long x, long m) {
    long ret = 1;
    while (x) {
        if (x % 2) ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}
0