結果

問題 No.1870 Xor Matrix
コンテスト
ユーザー 37zigen
提出日時 2023-04-13 14:28:05
言語 Scala(Beta)
(3.8.1)
コンパイル:
scalac _filename_
実行:
java -cp .:/home/linuxbrew/.linuxbrew/Cellar/scala/3.8.1/libexec/maven2/org/scala-lang/scala3-library_3/3.8.1/scala3-library_3-3.8.1.jar:/home/linuxbrew/.linuxbrew/Cellar/scala/3.8.1/libexec/maven2/org/scala-lang/scala-library/3.8.1/scala-library-3.8.1.jar _class_
結果
AC  
実行時間 811 ms / 2,000 ms
コード長 589 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 10,658 ms
コンパイル使用メモリ 270,160 KB
実行使用メモリ 80,316 KB
最終ジャッジ日時 2026-03-09 20:10:26
合計ジャッジ時間 27,384 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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