結果

問題 No.1210 XOR Grid
ユーザー kakel-san
提出日時 2025-04-29 23:30:30
言語 C#
(.NET 8.0.404)
結果
AC  
実行時間 180 ms / 2,000 ms
コード長 1,116 bytes
コンパイル時間 23,144 ms
コンパイル使用メモリ 171,780 KB
実行使用メモリ 188,976 KB
最終ジャッジ日時 2025-04-29 23:31:03
合計ジャッジ時間 16,762 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 57
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (131 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (h, w, x) = (c[0], c[1], c[2]);
        var a = NList;
        var b = NList;
        var ax = a.Aggregate((i, j) => i ^ j);
        var bx = b.Aggregate((i, j) => i ^ j);
        if (ax != bx)
        {
            WriteLine(0);
            return;
        }
        var mod = 1_000_000_007;
        WriteLine(Exp(Exp(2, (h - 1L) * (w - 1), mod), x, mod));
    }
    static long Exp(long n, long p, int mod)
    {
        long _n = n % mod;
        var _p = p;
        var result = 1L;
        if ((_p & 1) == 1) result *= _n;
        while (_p > 0)
        {
            _n = _n * _n % mod;
            _p >>= 1;
            if ((_p & 1) == 1) result = result * _n % mod;
        }
        return result;
    }
}
0