結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー 👑 obakyanobakyan
提出日時 2022-04-12 17:18:48
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 891 bytes
コンパイル時間 108 ms
コンパイル使用メモリ 5,300 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-22 22:13:07
合計ジャッジ時間 7,685 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 RE -
testcase_03 RE -
testcase_04 WA -
testcase_05 WA -
testcase_06 RE -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 RE -
testcase_20 WA -
testcase_21 RE -
testcase_22 WA -
testcase_23 RE -
testcase_24 WA -
testcase_25 RE -
testcase_26 WA -
testcase_27 WA -
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, n do
  print(table.concat(ret[i], " "))
end
0