結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー 👑 obakyanobakyan
提出日時 2022-04-12 17:19:37
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 894 bytes
コンパイル時間 46 ms
コンパイル使用メモリ 5,376 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-22 22:14:00
合計ジャッジ時間 5,398 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 8 ms
4,380 KB
testcase_04 AC 13 ms
4,380 KB
testcase_05 AC 13 ms
4,380 KB
testcase_06 AC 8 ms
4,376 KB
testcase_07 AC 13 ms
4,380 KB
testcase_08 AC 12 ms
4,380 KB
testcase_09 AC 12 ms
4,376 KB
testcase_10 AC 11 ms
4,380 KB
testcase_11 AC 12 ms
4,380 KB
testcase_12 AC 11 ms
4,376 KB
testcase_13 AC 10 ms
4,376 KB
testcase_14 AC 9 ms
4,376 KB
testcase_15 AC 10 ms
4,376 KB
testcase_16 AC 9 ms
4,380 KB
testcase_17 AC 9 ms
4,376 KB
testcase_18 AC 5 ms
4,376 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 6 ms
4,376 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 8 ms
4,380 KB
testcase_23 AC 8 ms
4,376 KB
testcase_24 AC 8 ms
4,376 KB
testcase_25 AC 8 ms
4,376 KB
testcase_26 AC 8 ms
4,380 KB
testcase_27 AC 8 ms
4,380 KB
testcase_28 AC 8 ms
4,380 KB
testcase_29 AC 8 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local bxor = bit.bxor
local mmi, mma = math.min, math.max

local n = io.read("*n")
local a, b = {}, {}
for i = 1, n do
  a[i] = io.read("*n")
end
for i = 1, n do
  b[i] = io.read("*n")
end
local max = 0
for i = 1, n do
  max = mma(max, a[i], b[i])
end
local mul = 1
while mul * 2 <= max do
  mul = mul * 2
end
local atgt = false
for i = 1, n do
  if mul <= a[i] then
    atgt = i break
  end
end
local ret = {}
if not atgt then
  for i = 1, n do
    if mul <= b[i] then
      a[1] = bxor(a[1], b[i])
      table.insert(ret, {1, 1, i})
      atgt = 1
      break
    end
  end
end
local v = a[atgt]
for i = 1, n do
  if b[i] < mul then
    table.insert(ret, {2, atgt, i})
    b[i] = bxor(b[i], v)
  end
end
v = b[1]
for i = 1, n do
  if mul <= a[i] then
    table.insert(ret, {1, i, 1})
    -- a[i] = bxor(a[i], v)
  end
end
print(#ret)
for i = 1, #ret do
  print(table.concat(ret[i], " "))
end
0