結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー 👑 obakyanobakyan
提出日時 2021-07-26 22:57:16
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 2,543 ms / 5,000 ms
コード長 990 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 5,216 KB
実行使用メモリ 115,896 KB
最終ジャッジ日時 2023-09-29 19:44:09
合計ジャッジ時間 43,469 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1,721 ms
107,264 KB
testcase_09 AC 375 ms
19,060 KB
testcase_10 AC 1,416 ms
64,568 KB
testcase_11 AC 927 ms
60,032 KB
testcase_12 AC 2,114 ms
114,728 KB
testcase_13 AC 2,171 ms
106,528 KB
testcase_14 AC 1,241 ms
59,660 KB
testcase_15 AC 2,478 ms
110,668 KB
testcase_16 AC 1,996 ms
115,372 KB
testcase_17 AC 2,259 ms
108,112 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 655 ms
108,828 KB
testcase_21 AC 2,543 ms
115,860 KB
testcase_22 AC 2,435 ms
115,772 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 3 ms
4,376 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 1,534 ms
65,308 KB
testcase_29 AC 2,191 ms
109,976 KB
testcase_30 AC 1,702 ms
115,896 KB
testcase_31 AC 1,521 ms
60,880 KB
testcase_32 AC 1,887 ms
114,592 KB
testcase_33 AC 2,499 ms
111,016 KB
testcase_34 AC 2,241 ms
109,896 KB
testcase_35 AC 2,475 ms
113,996 KB
testcase_36 AC 2,541 ms
113,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local ffi = require("ffi")
local C = ffi.C
ffi.cdef[[
long long atoll(const char*);
]]

local function lltonumber(str)
  return C.atoll(str)
end

local n = io.read("*n", "*l")
local str = io.read()
local a = {}
for w in str:gmatch("%d+") do
  table.insert(a, lltonumber(w))
end
local digmax = 61
local ret = 1LL
local t = {}
for i = 1, digmax do
  t[i] = {}
  for j = 1, n do
    t[i][j] = a[j] % 2LL == 1LL
    a[j] = a[j] / 2LL
  end
end
local rem = n
for j = 1, digmax do
  local tgt = 0
  local tj = t[j]
  for i = 1, rem do
    if tj[i] then
      ret = ret + ret
      tgt = i
      break
    end
  end
  if 0 < tgt then
    for i = tgt + 1, rem do
      if t[j][i] then
        for k = j + 1, digmax do
          if t[k][tgt] then t[k][i] = not t[k][i] end
        end
      end
    end
    if tgt < rem then
      for k = j + 1, digmax do
        t[k][tgt] = t[k][rem]
      end
    end
    rem = rem - 1
  end
end
ret = tostring(ret):gsub("LL", "")
print(ret)
-- print(os.clock())
0