Submission #5222

# Submission time Handle Problem Language Result Execution time Memory
5222 2014-02-18T05:32:53 Z kriii 초록색 삼각형 (YDX13_green) C++
1 / 1
216 ms 1148 KB
#include <stdio.h>
#include <algorithm>
using namespace std;

struct point{long long x,y;} P[2020],Q[2020];
bool cmp1(const point& a, const point& b){return a.y == b.x ? a.x < b.x : a.y < b.y;}
bool cmp2(const point& a, const point& b){return a.x * b.y < a.y * b.x;}

int main()
{
	int N;
	scanf ("%d",&N);
	for (int i=0;i<N;i++){
		scanf ("%lld %lld",&P[i].x,&P[i].y);
	}
	sort(P,P+N,cmp1);

	long double ans = 0;
	for (int i=0;i<N;i++){
		int c = 0;
		for (int j=i+1;j<N;j++){
			Q[c].x = P[j].x - P[i].x;
			Q[c].y = P[j].y - P[i].y;
			c++;
		}
		sort(Q,Q+c,cmp2);
		
		long double sx = 0, sy = 0;
		for (int j=0;j<c;j++){
			ans += Q[j].x * sy - Q[j].y * sx;
			sx += Q[j].x;
			sy += Q[j].y;
		}
	}

	if (N >= 3){
		ans /= N;
		ans /= N-1;
		ans /= N-2;
		ans *= 3;
	}

	printf ("%.12Lf\n",ans);

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1148 KB Output is correct
2 Correct 0 ms 1148 KB Output is correct
3 Correct 0 ms 1148 KB Output is correct
4 Correct 0 ms 1148 KB Output is correct
5 Correct 0 ms 1148 KB Output is correct
6 Correct 0 ms 1148 KB Output is correct
7 Correct 0 ms 1148 KB Output is correct
8 Correct 0 ms 1148 KB Output is correct
9 Correct 0 ms 1148 KB Output is correct
10 Correct 0 ms 1148 KB Output is correct
11 Correct 36 ms 1148 KB Output is correct
12 Correct 72 ms 1148 KB Output is correct
13 Correct 44 ms 1148 KB Output is correct
14 Correct 192 ms 1148 KB Output is correct
15 Correct 16 ms 1148 KB Output is correct
16 Correct 188 ms 1148 KB Output is correct
17 Correct 8 ms 1148 KB Output is correct
18 Correct 28 ms 1148 KB Output is correct
19 Correct 44 ms 1148 KB Output is correct
20 Correct 0 ms 1148 KB Output is correct
21 Correct 216 ms 1148 KB Output is correct
22 Correct 216 ms 1148 KB Output is correct
23 Correct 216 ms 1148 KB Output is correct
24 Correct 216 ms 1148 KB Output is correct
25 Correct 216 ms 1148 KB Output is correct
26 Correct 216 ms 1148 KB Output is correct
27 Correct 216 ms 1148 KB Output is correct
28 Correct 216 ms 1148 KB Output is correct
29 Correct 216 ms 1148 KB Output is correct
30 Correct 212 ms 1148 KB Output is correct
31 Correct 0 ms 1148 KB Output is correct