Submission #731693

# Submission time Handle Problem Language Result Execution time Memory
731693 2023-04-27T19:38:12 Z study Meandian (CEOI06_meandian) C++17
100 / 100
6 ms 208 KB
#include "libmean.h"
#include <bits/stdc++.h>
using namespace std;

int ans[100];

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	memset(ans,-1,sizeof(ans));
	int n = Init();
	queue<int> q;
	for (int i=1; i<=n; ++i) q.push(i);
	while (q.size() > 4){
		vector<int> idx;
		for (int i=0; i<5; ++i){
			idx.emplace_back(q.front());
			q.pop();
		}
		vector<pair<int,int>> queries = {
			{Meandian(idx[0],idx[1],idx[2],idx[3]),idx[4]},
			{Meandian(idx[0],idx[1],idx[2],idx[4]),idx[3]},
			{Meandian(idx[0],idx[1],idx[3],idx[4]),idx[2]},
			{Meandian(idx[0],idx[2],idx[3],idx[4]),idx[1]},
			{Meandian(idx[1],idx[2],idx[3],idx[4]),idx[0]}
		};
		sort(queries.begin(),queries.end());
		ans[queries[2].second-1] = queries[0].first+queries[4].first-queries[2].first;
		for (int i=0; i<5; ++i){
			if (i != 2) q.emplace(queries[i].second);
		}
	}
	Solution(ans);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 3 ms 208 KB Output is correct
8 Correct 5 ms 208 KB Output is correct
9 Correct 6 ms 208 KB Output is correct
10 Correct 5 ms 208 KB Output is correct