#include <bits/stdc++.h>
using namespace std;
using lint = long long;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int N, K;
cin >> N >> K;
vector<lint> X(N), Y(N);
for (int i = 0; i < N; i++) {
cin >> X[i] >> Y[i];
}
const auto Solve = [&](const auto &self, lint L, int k, vector<int> dead) -> pair<bool, vector<pair<int, int>>> {
if (count(begin(dead), end(dead), 1) == N) {
return {true, vector<pair<int, int>>(k, {0, 0})};
}
if (k == 0) {
return {false, vector<pair<int, int>>()};
}
lint minX = +2e9;
lint maxX = -2e9;
lint minY = +2e9;
lint maxY = -2e9;
for (int i = 0; i < N; i++) if (!dead[i]) {
minX = min(minX, X[i]);
maxX = max(maxX, X[i]);
minY = min(minY, Y[i]);
maxY = max(maxY, Y[i]);
}
for (auto x : {minX, maxX - L}) {
for (auto y : {minY, maxY - L}) {
vector<int> newDead = dead;
for (int i = 0; i < N; i++) if (!dead[i]) {
if (x <= X[i] && X[i] <= x + L && y <= Y[i] && Y[i] <= y + L) {
newDead[i] = 1;
}
}
auto res = self(self, L, k - 1, newDead);
if (res.first) {
res.second.emplace_back(x, y);
return res;
}
}
}
return {false, vector<pair<int, int>>()};
};
lint lo = 0, hi = 2e9;
while (lo < hi) {
lint md = (lo + hi) / 2;
if (Solve(Solve, md, K, vector<int>(N, 0)).first) {
hi = md;
} else {
lo = md + 1;
}
}
auto ans = Solve(Solve, lo, K, vector<int>(N, 0)).second;
for (int i = 0; i < K; i++) {
cout << ans[i].first << ' ' << ans[i].second << ' ' << lo << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Integer 0 violates the range [1, 2*10^9] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
308 KB |
Integer 0 violates the range [1, 2*10^9] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Integer 0 violates the range [1, 2*10^9] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |