Submission #420908

# Submission time Handle Problem Language Result Execution time Memory
420908 2021-06-08T14:47:56 Z maximath_1 Izvanzemaljci (COI21_izvanzemaljci) C++11
5 / 100
50 ms 3952 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;

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

pair<pair<int, int>, int> get_square(vector<pair<int, int> > pt){
	int mxx = pt[0].first, mnx = pt[0].first;
	int 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);
	}
	int sz = max(1, 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;

	int mx = 2000 * 1000 * 1000 + 696969;
	vector<pair<pair<int, int>, int> > 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<int, int>, int> > get(k);
		bool valid = 1; int 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<int, int>, int> get_square(std::vector<std::pair<int, int> >)':
izvanzemaljci.cpp:21:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for(int i = 1; i < pt.size(); i ++){
      |                 ~~^~~~~~~~~~~
izvanzemaljci.cpp:31:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for(int i = 0; i < pt.size(); i ++){
      |                 ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 38 ms 3824 KB Output is correct
8 Correct 31 ms 3904 KB Output is correct
9 Correct 32 ms 3952 KB Output is correct
10 Correct 32 ms 3900 KB Output is correct
11 Correct 50 ms 3852 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 2 ms 332 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -