蒟蒻怎么感觉二分+set+双指针的写法是O(n2)的呢?
inline bool check(int now) {
multiset<Node> s{};
head = 0, tail = -1, cnt = 0;
for (int i = 1; i <= n; i++) {
while (tail >= head && p[i].x - now > p[q[head]].x) s.erase(s.find({p[q[head]].x, p[q[head]].y})), head++;
auto pos = s.lower_bound({0, p[i].y - now});
while (pos != s.end() && p[i].y + now >= (*pos).y) {
res[++cnt] = max(abs(p[i].x - (*pos).x), abs(p[i].y - (*pos).y)), ++pos;
if (cnt >= k)
return true;
}
q[++tail] = i, s.insert({p[i].x, p[i].y});
}
return false;
}
这个check的复杂度是多少啊?