답안 #1002890

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1002890 2024-06-19T21:03:47 Z pedroslrey Izvanzemaljci (COI21_izvanzemaljci) C++14
5 / 100
87 ms 12628 KB
#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());
		d2 = max(d2, 1);

		cout << *xs.begin() << " " << *ys.begin() << " " << d2 << "\n";
		return 0;
	}

	if (n == 1) {
		cout << points[0].first << " " << points[0].second << " 1\n";
		cout << points[0].first + 2 << " " << points[0].second + 2 << " 1\n";
		return 0;
	}

	map<int, vector<pair<int, int>>> batch;
	for (auto [x, y]: points)
		batch[x].emplace_back(x, y);

	int mx_x = 0, mn_x = 1e9, mx_y = 0, mn_y = 1e9;
	vector<int> ans; lli best = 1e18;
	for (auto [k, abas]: batch) {
		for (auto [x, y]: abas) {
			assert(xs.find(x) != xs.end());
			assert(ys.find(y) != ys.end());

			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());
		d1 = max(d1, 1);
		d2 = max(d2, 1);

		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" : " ");
	cout << "\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:37:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   37 |  for (auto [x, y]: points)
      |            ^
izvanzemaljci.cpp:42:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   42 |  for (auto [k, abas]: batch) {
      |            ^
izvanzemaljci.cpp:43:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   43 |   for (auto [x, y]: abas) {
      |             ^
# 결과 실행 시간 메모리 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 85 ms 12600 KB Output is correct
8 Correct 87 ms 12588 KB Output is correct
9 Correct 82 ms 12628 KB Output is correct
10 Correct 85 ms 12468 KB Output is correct
11 Correct 85 ms 11112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 1116 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -