結果
問題 |
No.184 たのしい排他的論理和(HARD)
|
ユーザー |
👑 |
提出日時 | 2021-07-26 22:32:30 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,012 bytes |
コンパイル時間 | 98 ms |
コンパイル使用メモリ | 5,248 KB |
実行使用メモリ | 110,544 KB |
最終ジャッジ日時 | 2024-07-22 13:29:27 |
合計ジャッジ時間 | 19,490 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 WA * 4 |
ソースコード
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 f = {} for i = 1, 61 do f[i] = false end local rem = n for j = 1, 61 do if f[j] then for i = 1, rem do t[i][j] = not t[i][j] end end 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 k = j, 61 do if t[tgt][k] then f[k] = not f[k] 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) -- print(os.clock())