local gc = 0 local t = {} local function query(a, b) io.write("? " .. a .. " " .. b .. "\n") io.flush() -- do -- gc = gc + 1 -- if b == t[1] then return false end -- if a == t[#t] then return false end -- return false -- end local ret = io.read("*l") return tonumber(ret) == 1 end local n = io.read("*n", "*l") local f = query(1, 2) if f then table.insert(t, 1) table.insert(t, 2) else table.insert(t, 2) table.insert(t, 1) end for i = 3, n do if false and query(i, t[1]) then table.insert(t, 1, i) elseif false and query(t[#t], i) then table.insert(t, i) else local left, right = 0, #t + 1 while 1 < right - left do local mid = math.floor((left + right) / 2) if query(i, t[mid]) then right = mid else left = mid end end table.insert(t, right, i) end end -- print("GC", gc) io.write("!\n") io.write(n - 1 .. "\n") io.write(table.concat(t, " ") .. "\n") io.flush()