結果
問題 |
No.184 たのしい排他的論理和(HARD)
|
ユーザー |
👑 |
提出日時 | 2021-07-26 22:57:16 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 2,342 ms / 5,000 ms |
コード長 | 990 bytes |
コンパイル時間 | 117 ms |
コンパイル使用メモリ | 5,248 KB |
実行使用メモリ | 115,716 KB |
最終ジャッジ日時 | 2024-07-22 13:48:58 |
合計ジャッジ時間 | 38,964 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
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())