結果

問題 No.1210 XOR Grid
ユーザー yuruhiyayuruhiya
提出日時 2020-10-20 19:44:39
言語 Crystal
(1.11.2)
結果
RE  
実行時間 -
コード長 1,525 bytes
コンパイル時間 19,101 ms
コンパイル使用メモリ 253,968 KB
実行使用メモリ 27,404 KB
最終ジャッジ日時 2023-09-13 12:22:34
合計ジャッジ時間 23,220 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,472 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,408 KB
testcase_04 AC 2 ms
4,500 KB
testcase_05 AC 3 ms
4,400 KB
testcase_06 AC 2 ms
4,400 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,404 KB
testcase_10 AC 3 ms
4,408 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 3 ms
4,488 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 3 ms
4,400 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,504 KB
testcase_35 AC 3 ms
4,380 KB
testcase_36 AC 18 ms
13,984 KB
testcase_37 AC 18 ms
14,044 KB
testcase_38 AC 17 ms
13,904 KB
testcase_39 AC 15 ms
11,044 KB
testcase_40 AC 30 ms
19,676 KB
testcase_41 AC 30 ms
17,800 KB
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 AC 35 ms
19,760 KB
testcase_48 AC 35 ms
19,672 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 49 ms
27,404 KB
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 AC 33 ms
19,792 KB
testcase_55 AC 55 ms
27,380 KB
testcase_56 RE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

lib C
  fun strtoll(s : UInt8*, p : UInt8**, b : Int32) : Int64
end

class String
  def to_i64
    C.strtoll(self, nil, 10)
  end
end

struct ModInt
  @@MOD = 1_000_000_007i64

  def self.mod
    @@MOD
  end

  def self.zero
    ModInt.new(0)
  end

  def initialize(n)
    @n = n.to_i64 % @@MOD
  end

  getter n : Int64

  def + : self
    self
  end

  def - : self
    ModInt.new(n != 0 ? @@MOD - @n : 0)
  end

  def +(m)
    ModInt.new(@n + m.to_i64 % @@MOD)
  end

  def -(m)
    ModInt.new(@n - m.to_i64 % @@MOD)
  end

  def *(m)
    ModInt.new(@n * m.to_i64 % @@MOD)
  end

  def /(m)
    raise DivisionByZeroError.new if m == 0
    a, b, u, v = m.to_i64, @@MOD, 1i64, 0i64
    while b != 0
      t = a // b
      a -= t * b
      a, b = b, a
      u -= t * v
      u, v = v, u
    end
    ModInt.new(@n * u)
  end

  def //(m)
    self / m
  end

  def **(m : Int)
    t, res = self, ModInt.new(1)
    while m > 0
      res *= t if m.odd?
      t *= t
      m >>= 1
    end
    res
  end

  def ==(m)
    @n == m.to_i64
  end

  def !=(m)
    @n != m.to_i64
  end

  def succ
    self + 1
  end

  def pred
    self - 1
  end

  def to_i64 : Int64
    @n
  end

  delegate to_s, to: @n
  delegate inspect, to: @n
end

struct Int
  def to_mint : ModInt
    ModInt.new(self)
  end
end

n, m, x = read_line.split.map(&.to_i)
a = read_line.split.map(&.to_i)
b = read_line.split.map(&.to_i)

if a.reduce { |x, y| x ^ y } == b.reduce { |x, y| x ^ y }
  puts 2.to_mint ** ((n - 1).to_i64 * (m - 1) * x)
else
  puts 0
end
0