結果
問題 |
No.184 たのしい排他的論理和(HARD)
|
ユーザー |
👑 |
提出日時 | 2021-07-26 22:27:51 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
TLE
|
実行時間 | - |
コード長 | 966 bytes |
コンパイル時間 | 296 ms |
コンパイル使用メモリ | 6,944 KB |
実行使用メモリ | 99,004 KB |
最終ジャッジ日時 | 2024-07-22 13:26:08 |
合計ジャッジ時間 | 31,583 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 TLE * 4 -- * 20 |
ソースコード
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)