結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー 👑 obakyanobakyan
提出日時 2021-07-26 22:27:51
言語 Lua
(LuaJit 2.1.1696795921)
結果
TLE  
実行時間 -
コード長 966 bytes
コンパイル時間 119 ms
コンパイル使用メモリ 5,212 KB
実行使用メモリ 119,400 KB
最終ジャッジ日時 2023-09-29 19:21:14
合計ジャッジ時間 87,895 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3,771 ms
87,924 KB
testcase_09 AC 632 ms
18,240 KB
testcase_10 AC 2,958 ms
63,544 KB
testcase_11 AC 2,004 ms
51,560 KB
testcase_12 AC 4,386 ms
111,308 KB
testcase_13 AC 4,814 ms
112,652 KB
testcase_14 AC 2,684 ms
60,776 KB
testcase_15 TLE -
testcase_16 AC 4,127 ms
108,404 KB
testcase_17 AC 4,664 ms
114,588 KB
testcase_18 AC 2 ms
4,504 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 781 ms
101,552 KB
testcase_21 TLE -
testcase_22 TLE -
testcase_23 AC 4 ms
4,380 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 AC 4 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
testcase_36 TLE -
権限があれば一括ダウンロードができます

ソースコード

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 ret = 1LL
local t = {}
for i = 1, n do
  t[i] = {}
  local ai = a[i]
  for j = 1, 61 do
    t[i][j] = ai % 2LL == 1LL
    ai = ai / 2LL
  end
end
local rem = n
for j = 1, 61 do
  local tgt = 0
  for i = 1, rem do
    if t[i][j] then
      ret = ret + ret
      tgt = i
      break
    end
  end
  if 0 < tgt then
    for i = 1, rem do
      if i ~= tgt then
        for k = j, 61 do
          if t[tgt][k] then
            t[i][k] = not t[i][k]
          end
        end
      end
    end
    if tgt < rem then
      for k = j + 1, 61 do
        t[tgt][k], t[rem][k] = t[rem][k], t[tgt][k]
      end
    end
    rem = rem - 1
  end
end
ret = tostring(ret):gsub("LL", "")
print(ret)
0