Submission #262899

# Submission time Handle Problem Language Result Execution time Memory
262899 2020-08-13T10:41:24 Z dolphingarlic Meandian (CEOI06_meandian) C++14
100 / 100
5 ms 256 KB
#include "libmean.h"
#include <bits/stdc++.h>
using namespace std;

int ans[100], c[5];

int main() {
	int n = Init();
	fill(ans, ans + n, -1);
	queue<int> cand;
	for (int i = 1; i <= n; i++) cand.push(i);
	while (cand.size() > 4) {
		for (int i = 0; i < 5; i++) {
			c[i] = cand.front();
			cand.pop();
		}
		vector<pair<int, int>> occ = {
			{Meandian(c[0], c[1], c[2], c[3]), c[4]},
			{Meandian(c[0], c[1], c[2], c[4]), c[3]},
			{Meandian(c[0], c[1], c[3], c[4]), c[2]},
			{Meandian(c[0], c[2], c[3], c[4]), c[1]},
			{Meandian(c[1], c[2], c[3], c[4]), c[0]}
		};
		sort(occ.begin(), occ.end());
		ans[occ[2].second - 1] = occ[0].first + occ[4].first - occ[2].first;
		for (int i = 0; i < 5; i++) if (i != 2) cand.push(occ[i].second);
	}
	Solution(ans);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct