結果

問題 No.1870 Xor Matrix
コンテスト
ユーザー 37zigen
提出日時 2023-04-13 14:28:05
言語 Scala(Beta)
(3.8.2)
コンパイル:
scalac _filename_
実行:
/usr/bin/scala_run _class_
結果
AC  
実行時間 556 ms / 2,000 ms
+ 532µs
コード長 589 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 7,452 ms
コンパイル使用メモリ 280,796 KB
実行使用メモリ 83,292 KB
最終ジャッジ日時 2026-07-28 18:22:53
合計ジャッジ時間 19,976 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import scala.io.StdIn.readLine

object Main {
  def main(args: Array[String]): Unit = {
    val Array(n, m) = readLine().split(" ").map(_.toLong)
    val row = readLine().split(" ").map(_.toInt)
    val column = readLine().split(" ").map(_.toInt)
    if (row.fold(0)(_ ^ _) == column.fold(0)(_ ^ _)) {
      println(powMod(1 << 20, (n - 1) * (m - 1)))
    } else {
      println(0)
    }
  }

  val MOD = 998244353;

  def powMod(base : Long, exp : Long): Long = {
    if (exp == 0) 1
    else {
      (if (exp % 2 == 1) base else 1) * powMod(base * base % MOD, exp / 2) % MOD
    }
  }
}
0