Submission #136458

# Submission time Handle Problem Language Result Execution time Memory
136458 2019-07-25T10:29:34 Z onjo0127 Meandian (CEOI06_meandian) C++11
100 / 100
9 ms 376 KB
#include "libmean.h"
#include <bits/stdc++.h>
using namespace std;

int N, A[111];

void solve(vector<int> &S) {
	if((int)S.size() == 4) {
		for(auto& it: S) A[it-1] = -1;
		return;
	}
	int a0 = Meandian(S[1], S[2], S[3], S[4]);
	int a1 = Meandian(S[0], S[2], S[3], S[4]);
	int a2 = Meandian(S[0], S[1], S[3], S[4]);
	int a3 = Meandian(S[0], S[1], S[2], S[4]);
	int a4 = Meandian(S[0], S[1], S[2], S[3]);
	int v1 = a0 ^ a1 ^ a2 ^ a3 ^ a4;
	int v2 = a0 + a1 + a2 + a3 + a4 - v1;
	int ans = (2*v1 + v2) / 2 - 2*v1;
	if(a0 == v1) {A[S[0]-1] = ans; S.erase(S.begin() + 0);}
	if(a1 == v1) {A[S[1]-1] = ans; S.erase(S.begin() + 1);}
	if(a2 == v1) {A[S[2]-1] = ans; S.erase(S.begin() + 2);}
	if(a3 == v1) {A[S[3]-1] = ans; S.erase(S.begin() + 3);}
	if(a4 == v1) {A[S[4]-1] = ans; S.erase(S.begin() + 4);}
	solve(S);
}

int main() {
	N = Init();
	vector<int> S;
	for(int i=1; i<=N; i++) S.push_back(i);
	solve(S);
	Solution(A);
	return 0;
} 
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 2 ms 248 KB Output is correct
6 Correct 3 ms 248 KB Output is correct
7 Correct 3 ms 248 KB Output is correct
8 Correct 7 ms 376 KB Output is correct
9 Correct 8 ms 248 KB Output is correct
10 Correct 9 ms 376 KB Output is correct