#include <bits/stdc++.h>
using namespace std;
using lli = long long;
int main() {
int n, k;
cin >> n >> k;
vector<pair<int, int>> points(n);
for (auto &[x, y]: points)
cin >> x >> y;
sort(points.begin(), points.end());
multiset<int> xs, ys;
for (auto [x, y]: points) {
xs.insert(x);
ys.insert(y);
}
if (k == 1) {
int d2 = max(*xs.rbegin() - *xs.begin(), *ys.rbegin() - *ys.begin());
cout << *xs.begin() << " " << *ys.begin() << " " << d2 << "\n";
return 0;
}
int mx_x = 0, mn_x = 1e9, mx_y = 0, mn_y = 1e9;
vector<int> ans; lli best = 1e18;
for (auto [x, y]: points) {
mx_x = max(mx_x, x); mn_x = min(mn_x, x);
mx_y = max(mx_y, y); mn_y = min(mn_y, y);
xs.erase(xs.find(x)); ys.erase(ys.find(y));
if (xs.empty()) break;
int d1 = max(mx_x - mn_x, mx_y - mn_y);
int d2 = max(*xs.rbegin() - *xs.begin(), *ys.rbegin() - *ys.begin());
lli cost1 = 1LL*d1*d1;
lli cost2 = 1LL*d2*d2;
if (cost1 + cost2 < best) {
best = cost1 + cost2;
ans = vector<int>{mn_x, mn_y, d1, *xs.begin(), *ys.begin(), d2};
}
}
for (int i = 0; i < 6; ++i)
cout << ans[i] << (i == 2 ? "\n" : " ");
}
Compilation message
izvanzemaljci.cpp: In function 'int main()':
izvanzemaljci.cpp:11:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
11 | for (auto &[x, y]: points)
| ^
izvanzemaljci.cpp:17:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
17 | for (auto [x, y]: points) {
| ^
izvanzemaljci.cpp:31:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
31 | for (auto [x, y]: points) {
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Integer 0 violates the range [1, 2*10^9] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |