結果

問題 No.1870 Xor Matrix
ユーザー 👑 obakyanobakyan
提出日時 2022-03-22 22:07:30
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 934 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 5,376 KB
実行使用メモリ 6,016 KB
最終ジャッジ日時 2024-04-18 22:54:20
合計ジャッジ時間 3,122 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 42 ms
5,376 KB
testcase_04 AC 61 ms
5,888 KB
testcase_05 AC 42 ms
5,376 KB
testcase_06 AC 43 ms
5,376 KB
testcase_07 AC 52 ms
5,888 KB
testcase_08 AC 61 ms
5,760 KB
testcase_09 AC 33 ms
5,376 KB
testcase_10 AC 52 ms
5,376 KB
testcase_11 AC 55 ms
5,376 KB
testcase_12 AC 49 ms
5,376 KB
testcase_13 AC 31 ms
5,376 KB
testcase_14 AC 57 ms
6,016 KB
testcase_15 AC 32 ms
5,376 KB
testcase_16 AC 38 ms
5,376 KB
testcase_17 AC 61 ms
6,016 KB
testcase_18 AC 51 ms
5,376 KB
testcase_19 AC 54 ms
5,376 KB
testcase_20 AC 41 ms
5,376 KB
testcase_21 AC 28 ms
5,376 KB
testcase_22 AC 40 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mod = 998244353
local mfl = math.floor
local function bmul(x, y)
  local x0, y0 = x % 31596, y % 31596
  local x1, y1 = mfl(x / 31596), mfl(y / 31596)
  return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod
end
local function modpow(src, pow)
  local res = 1
  while 0 < pow do
    if pow % 2 == 1 then
      res = bmul(res, src)
      pow = pow - 1
    end
    src = bmul(src, src)
    pow = mfl(pow / 2)
  end
  return res
end


local n, m = io.read("*n", "*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
local b = {}
for i = 1, m do
  b[i] = io.read("*n")
end
for i = 1, 20 do
  local az = 0
  for j = 1, n do
    az = az + a[j] % 2
    a[j] = mfl(a[j] / 2)
  end
  local bz = 0
  for j = 1, m do
    bz = bz + b[j] % 2
    b[j] = mfl(b[j] / 2)
  end
  if (az + bz) % 2 == 1 then print(0) os.exit() end
end
if n == 1 or m == 1 then
  print(1)
else
  print(modpow(2, (n - 1) * (m - 1) * 20))
end
0