結果

問題 No.1210 XOR Grid
ユーザー yuruhiyayuruhiya
提出日時 2020-10-20 19:45:39
言語 Crystal
(1.11.2)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 1,529 bytes
コンパイル時間 21,389 ms
コンパイル使用メモリ 253,388 KB
実行使用メモリ 31,932 KB
最終ジャッジ日時 2023-09-13 12:22:07
合計ジャッジ時間 24,792 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,456 KB
testcase_02 AC 3 ms
4,484 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,500 KB
testcase_05 AC 2 ms
4,408 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,508 KB
testcase_08 AC 2 ms
4,516 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 2 ms
4,404 KB
testcase_11 AC 2 ms
4,456 KB
testcase_12 AC 2 ms
4,432 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,440 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,568 KB
testcase_19 AC 2 ms
4,432 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 3 ms
4,444 KB
testcase_22 AC 2 ms
4,412 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 38 ms
19,260 KB
testcase_26 AC 38 ms
21,192 KB
testcase_27 AC 38 ms
21,132 KB
testcase_28 AC 39 ms
21,184 KB
testcase_29 AC 41 ms
21,168 KB
testcase_30 AC 34 ms
19,024 KB
testcase_31 AC 39 ms
21,116 KB
testcase_32 AC 38 ms
19,264 KB
testcase_33 AC 2 ms
4,492 KB
testcase_34 AC 3 ms
4,440 KB
testcase_35 AC 2 ms
4,444 KB
testcase_36 AC 20 ms
14,628 KB
testcase_37 AC 20 ms
14,776 KB
testcase_38 AC 19 ms
14,700 KB
testcase_39 AC 20 ms
12,632 KB
testcase_40 AC 33 ms
19,236 KB
testcase_41 AC 34 ms
19,172 KB
testcase_42 AC 73 ms
31,276 KB
testcase_43 AC 68 ms
29,040 KB
testcase_44 AC 72 ms
29,904 KB
testcase_45 AC 72 ms
31,300 KB
testcase_46 AC 70 ms
28,696 KB
testcase_47 AC 36 ms
19,328 KB
testcase_48 AC 37 ms
19,112 KB
testcase_49 AC 3 ms
4,624 KB
testcase_50 AC 55 ms
28,780 KB
testcase_51 AC 70 ms
29,132 KB
testcase_52 AC 62 ms
31,932 KB
testcase_53 AC 73 ms
29,132 KB
testcase_54 AC 35 ms
19,224 KB
testcase_55 AC 59 ms
28,676 KB
testcase_56 AC 40 ms
19,348 KB
testcase_57 AC 47 ms
24,364 KB
testcase_58 AC 3 ms
4,460 KB
testcase_59 AC 2 ms
4,544 KB
権限があれば一括ダウンロードができます

ソースコード

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_i64)
b = read_line.split.map(&.to_i64)

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