#include <bits/stdc++.h>
//#include<ext/rope>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC target("avx2")
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#define F first
#define S second
#define pb push_back
#define sz(x) int(x.size())
#define el '\n'
#define all(x) x.begin(), x.end()
using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
typedef long long ll;
typedef long double ld;
typedef short int si;
typedef unsigned long long ull;
//typedef tree <ll, null_type, less <ll> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
vector <ll> X[3], Y[3];
pair <pair <ll, ll>, ll> solve(vector <ll> &x, vector <ll> &y) {
ll mn_x = 1e9, mx_x = -1e9;
ll mn_y = 1e9, mx_y = -1e9;
for (int i = 0; i < sz(x); i++) {
mn_x = min(mn_x, x[i]); mn_y = min(mn_y, y[i]);
mx_x = max(mx_x, x[i]); mx_y = max(mx_y, y[i]);
}
return {{mn_x, mn_y}, max(1ll, max(mx_x - mn_x, mx_y - mn_y))};
}
ll calc(pair <pair <ll, ll>, ll> a) {
return a.S * a.S;
}
int main()
{
// cerr.precision(7);
// cerr << fixed;
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// in("23.in");
// in("input.txt");
// out("output.txt");
// clock_t start = clock();
int n, k;
cin >> n >> k;
vector <ll > x(n), y(n);
for (int i = 0; i < n; i++) {
cin >> x[i] >> y[i];
}
if (k == 1) {
pair <pair <ll, ll>, ll> cur = solve(x, y);
cout << cur.F.F << " " << cur.F.S << " " << cur.S << el;
return 0;
}
int mxmask = 1;
for (int i = 0; i < n; i++) {
mxmask *= 3;
}
ll ans = 4e18;
int mmask;
for (int mask = 0; mask < mxmask; mask++) {
for (int i = 0; i < 3; i++) {
X[i].clear(); Y[i].clear();
}
for (int m = mask, i = 0; i < n; i++, m /= 3) {
X[m % 3].pb(x[i]);
Y[m % 3].pb(y[i]);
}
ll cur = 0;
for (int i = 0; i < 3; i++) {
cur = max(cur, calc(solve(X[i], Y[i])));
}
if (ans > cur) {
ans = min(ans, cur);
mmask = mask;
}
}
// cout << ans << el;
for (int i = 0; i < 3; i++) {
X[i].clear(); Y[i].clear();
}
for (int m = mmask, i = 0; i < n; i++, m /= 3) {
X[m % 3].pb(x[i]);
Y[m % 3].pb(y[i]);
}
for (int i = 0; i < 3; i++) {
if (!sz(X[i])) {
cout << ((ll)2e9 + i) << " " << ((ll)2e9 + i) << " 1" << el;
continue;
}
pair <pair <ll, ll>, ll> cur = solve(X[i], Y[i]);
cout << cur.F.F << " " << cur.F.S << " " << cur.S << el;
}
}
Compilation message
izvanzemaljci.cpp: In function 'int main()':
izvanzemaljci.cpp:97:13: warning: 'mmask' may be used uninitialized in this function [-Wmaybe-uninitialized]
97 | X[m % 3].pb(x[i]);
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
21 ms |
1892 KB |
Output is correct |
8 |
Correct |
32 ms |
1892 KB |
Output is correct |
9 |
Correct |
20 ms |
1868 KB |
Output is correct |
10 |
Correct |
19 ms |
1868 KB |
Output is correct |
11 |
Correct |
20 ms |
1868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3048 ms |
332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3072 ms |
332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |