Submission #420910

# Submission time Handle Problem Language Result Execution time Memory
420910 2021-06-08T14:50:44 Z maximath_1 Izvanzemaljci (COI21_izvanzemaljci) C++11
5 / 100
34 ms 6116 KB
#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <set>
#include <string>
#include <vector>
#include <random>
#include <deque>
using namespace std;

mt19937 rng(420691273);
#define ll long long
const int MX = 5e3 + 5;
const ll inf = 1e18 + 69;

int n, k;
vector<pair<ll, ll> > v, owo[3];

pair<pair<ll, ll>, ll> get_square(vector<pair<ll, ll> > pt){
	ll mxx = pt[0].first, mnx = pt[0].first;
	ll mxy = pt[0].second, mny = pt[0].second;
	for(int i = 1; i < pt.size(); i ++){
		mxx = max(mxx, pt[i].first);
		mnx = min(mnx, pt[i].first);
		mxy = max(mxy, pt[i].second);
		mny = min(mny, pt[i].second);
	}
	ll sz = max(1ll, max(mxx - mnx, mxy - mny));

	// check validity
	bool ok = 1;
	for(int i = 0; i < pt.size(); i ++){
		if(pt[i].first < mnx || pt[i].first > mnx + sz || pt[i].second < mny || pt[i].second > mny + sz)
			ok = 0;
	}

	if(ok) return {{mnx, mny}, sz};
	else return {{-1, -1}, -1};
}

int main(){
	cin.tie(0) -> sync_with_stdio(0);

	cin >> n >> k;
	v.resize(n);
	for(int i = 0; i < n; i ++)
		cin >> v[i].first >> v[i].second;

	int all = 1;
	for(int i = 0; i < n; i ++) all *= k;

	ll mx = inf;
	vector<pair<pair<ll, ll>, ll> > ans;
	for(int msk = 0; msk < all; msk ++){
		for(int i = 0; i < k; i ++) owo[i].clear();
		for(int tmp = msk, i = 0; i < n; i ++, tmp /= k)
			owo[tmp % k].push_back(v[i]);

		vector<pair<pair<ll, ll>, ll> > get(k);
		bool valid = 1; ll mx_nw = 0ll;
		for(int i = 0; i < k; i ++){
			if(owo[i].empty()){
				valid = 0; break;
			}
			get[i] = get_square(owo[i]);
			if(get[i].second == -1) valid = 0;
			mx_nw = max(mx_nw, get[i].second);
		}

		if(valid && mx > mx_nw){
			mx = mx_nw;
			ans = get;
		}
	}

	for(auto i : ans)
		cout << i.first.first << " " << i.first.second << " " << i.second << endl;
	return 0;
}

Compilation message

izvanzemaljci.cpp: In function 'std::pair<std::pair<long long int, long long int>, long long int> get_square(std::vector<std::pair<long long int, long long int> >)':
izvanzemaljci.cpp:22:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for(int i = 1; i < pt.size(); i ++){
      |                 ~~^~~~~~~~~~~
izvanzemaljci.cpp:32:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for(int i = 0; i < pt.size(); i ++){
      |                 ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 316 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 34 ms 6076 KB Output is correct
8 Correct 34 ms 6116 KB Output is correct
9 Correct 32 ms 6088 KB Output is correct
10 Correct 31 ms 6052 KB Output is correct
11 Correct 32 ms 6060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 240 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -