#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct Answer {
int ans = 2e9 + 7;
vector<vector<ll>> res;
void norm(int k) {
int t = 0;
ll x = 2.5e9, y = 2.5e9;
while (res.size() < k) {
res.push_back({x, y, 1});
t += 1;
if (t & 1) {
x = -x;
}
if (t & 2) {
y = -y;
}
}
}
};
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> k;
vector<pair<int, int>> a(n);
for (auto &[x, y] : a) {
cin >> x >> y;
}
Answer ans{};
ans.ans = 2e9 + 7;
if (k >= 1) {
int minx = 2e9, maxx = -2e9, miny = 2e9, maxy = -2e9;
for (auto &[x, y] : a) {
minx = min(minx, x);
maxx = max(maxx, x);
miny = min(miny, y);
maxy = max(maxy, y);
}
int d = max({1, maxy - miny, maxx - minx});
ans.ans = d;
ans.res = {vector<ll>{minx, miny, d}};
}
if (k >= 2) {
for (int t = 0; t < 2; ++t) {
Answer now{};
sort(a.begin(), a.end());
vector<int> mn(n + 1, 2e9), mx(n + 1, -2e9);
for (int i = n - 1; i >= 0; --i) {
mn[i] = min(mn[i + 1], a[i].second);
mx[i] = max(mx[i + 1], a[i].second);
}
int mny = 2e9, mxy = -2e9;
for (int i = 0; i < n; ++i) {
mny = min(mny, a[i].second);
mxy = max(mxy, a[i].second);
if (i + 1 < n && a[i + 1].first != a[i].first) {
int d = max({1, mxy - mny, mx[i + 1] - mn[i + 1], a[i].first - a[0].first, a.back().first - a[i + 1].first});
if (now.ans > d) {
now.ans = d;
now.res.clear();
int rx = a[i].first;
int ry = mxy;
now.res.push_back({rx - d, ry - d, d});
int lx = a[i + 1].first;
int ly = mn[i + 1];
now.res.push_back({lx, ly, d});
}
}
}
if (t == 1) {
for (auto &f : now.res) {
swap(f[0], f[1]);
}
}
if (ans.ans > now.ans) {
ans = now;
}
for (auto &[x, y]: a) {
swap(x, y);
}
}
}
ans.norm(k);
for (auto &t : ans.res) {
for (auto x : t) {
cout << x << " ";
}
cout << '\n';
}
return 0;
}
Compilation message
izvanzemaljci.cpp: In member function 'void Answer::norm(int)':
izvanzemaljci.cpp:13:27: warning: comparison of integer expressions of different signedness: 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
13 | while (res.size() < k) {
| ~~~~~~~~~~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
15 ms |
1116 KB |
Output is correct |
8 |
Correct |
19 ms |
1116 KB |
Output is correct |
9 |
Correct |
14 ms |
1116 KB |
Output is correct |
10 |
Correct |
16 ms |
1112 KB |
Output is correct |
11 |
Correct |
15 ms |
1116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Incorrect |
31 ms |
1996 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |