結果
| 問題 |
No.130 XOR Minimax
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2020-04-23 21:31:53 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 957 bytes |
| コンパイル時間 | 156 ms |
| コンパイル使用メモリ | 6,948 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-13 23:39:25 |
| 合計ジャッジ時間 | 2,324 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 WA * 19 |
ソースコード
local bls, brs = bit.lshift, bit.rshift
local mfl = math.floor
local mmi, mma = math.min, math.max
local function comp(a, b)
return a < b
end
local function lower_bound(ary, min, max, x)
if not comp(ary[min], x) then return min end
if comp(ary[max], x) then return max + 1 end
while 1 < max - min do
local mid = mfl((min + max) / 2)
if comp(ary[mid], x) then
min = mid
else
max = mid
end
end
return max
end
local n = io.read("*n")
local a = {}
for i = 1, n do
a[i] = io.read("*n")
end
table.sort(a)
local ret = 1000000007
local function rec(l, r, stage, score)
local mask = 0
for i = stage, 0, -1 do
local lb = lower_bound(a, l, r, mask + bls(1, i))
if lb <= l then
mask = mask + bls(1, i)
elseif r < lb then
else
rec(l, lb - 1, i - 1, score + bls(1, i))
rec(lb, r, i - 1, score + bls(1, i))
return
end
end
ret = mmi(ret, score)
end
rec(1, n, 29, 0)
print(ret)