Submission #136300

# Submission time Handle Problem Language Result Execution time Memory
136300 2019-07-25T06:00:18 Z 김세빈(#3258) Meandian (CEOI06_meandian) C++14
0 / 100
6 ms 504 KB
#include <bits/stdc++.h>

#include "libmean.h"

using namespace std;

int A[111];
int n;

int getidx(int i1, int i2, int i3, int i4, int i5, bool f)
{
	int v1 = Meandian(i2, i3, i4, i5);
	int v2 = Meandian(i1, i3, i4, i5);
	int v3 = Meandian(i1, i2, i4, i5);
	int v4 = Meandian(i1, i2, i3, i5);
	int v5 = Meandian(i1, i2, i3, i4);
	int v = (f? max({v1, v2, v3, v4, v5}) : min({v1, v2, v3, v4, v5}));
	if(v == v1) return i1;
	if(v == v2) return i2;
	if(v == v3) return i3;
	if(v == v4) return i4;
	if(v == v5) return i5;
}

int find(bool f)
{
	vector <int> V;
	int m, i;
	
	m = 1;
	
	for(i=5; i<=n; i+=4){
		m = getidx(m, i - 3, i - 2, i - 1, i, f);
	}
	
	V.clear();
	
	for(i=n; V.size() < 4; i--){
		if(i != m) V.push_back(i);
	}
	
	m = getidx(m, V[0], V[1], V[2], V[3], f);
	
	return m;
}

void findval(vector <int> &V, int m1, int m2)
{
	int i, v;
	int v1 = Meandian(m1, m2, V[1], V[2]);
	int v2 = Meandian(m1, m2, V[0], V[2]);
	int v3 = Meandian(m1, m2, V[0], V[1]);
	int s = v1 + v2 + v3;
	
	A[V[0] - 1] = s - v1 * 2;
	A[V[1] - 1] = s - v2 * 2;
	A[V[2] - 1] = s - v3 * 2;
	
	for(i=3; i<V.size(); i++){
		A[V[i] - 1] = Meandian(m1, m2, V[0], V[i]) * 2 - A[V[0] - 1];
	}
}

int main()
{
	vector <int> V;
	int i, m1, m2;
	
	n = Init();
	
	for(i=1; i<=n; i++){
		A[i - 1] = -1;
	}
	
	if(n <= 4){
		Solution(A);
		return 0;
	}
	
	m1 = find(0); m2 = find(1);
	
	for(i=1; i<=n; i++){
		if(i != m1 && i != m2){
			V.push_back(i);
		}
	}
	
	findval(V, m1, m2);
/*	
	for(i=0; i<n; i++){
		printf("%d ", A[i]);
	}
	
	printf("\n");
*/	
	Solution(A);
	
	return 0;
}

Compilation message

meandian.cpp: In function 'void findval(std::vector<int>&, int, int)':
meandian.cpp:59:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=3; i<V.size(); i++){
           ~^~~~~~~~~
meandian.cpp:49:9: warning: unused variable 'v' [-Wunused-variable]
  int i, v;
         ^
meandian.cpp: In function 'int getidx(int, int, int, int, int, bool)':
meandian.cpp:23:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB number 4 is wrong (138, should be -1)
2 Incorrect 2 ms 248 KB number 2 is wrong (1482, should be -1)
3 Incorrect 3 ms 504 KB number 1 is wrong (-1, should be 340)
4 Incorrect 2 ms 248 KB number 2 is wrong (-1, should be 1688)
5 Incorrect 2 ms 248 KB number 12 is wrong (126, should be -1)
6 Incorrect 3 ms 376 KB number 4 is wrong (-1, should be 322)
7 Incorrect 4 ms 248 KB number 13 is wrong (1958, should be -1)
8 Incorrect 5 ms 248 KB number 1 is wrong (-1, should be 1832)
9 Incorrect 5 ms 380 KB number 8 is wrong (196, should be 130)
10 Incorrect 6 ms 376 KB number 1 is wrong (-1, should be 1990)