#include<stdio.h>
#include<algorithm>
#include<math.h>
typedef long long ll;
const double PI = 3.141592653589793238;
int x[2020], y[2020], ord[2020];
double an[2020];
int n;
bool comp(const int &a,const int &b){return an[a] < an[b];}
inline ll ccw(int a,int b,int c)
{
return (ll)(x[b]-x[a]) * (y[c]-y[a]) - (ll)(x[c]-x[a]) * (y[b]-y[a]);
}
int main()
{
scanf("%d",&n);
int i, j;
for(i=1;i<=n;i++)scanf("%d%d",x+i,y+i);
if(n<=2)return printf("0")&0;
for(i=1;i<=n;i++)ord[i] = i;
double ans = 0;
for(i=1;i<=n;i++){
for(j=1;j<=n;j++)an[j] = atan2(y[j] - y[i], x[j] - x[i]);
std::sort(ord+1,ord+1+n,comp);
int t = (ord[1] == i)?2:1;
ll now[2] = {0,0};
for(j=1;j<=n;j++){
int nj = ord[j];
if(nj == i)continue;
now[0] -= x[nj] - x[i], now[1] -= y[nj] - y[i];
while(ord[t] == i || t == j)now[0] += x[ord[t]] - x[i], now[1] += y[ord[t]] - y[i], t = t%n + 1;
while(t!=j && ccw(i,ord[j],ord[t]) > 0){
now[0] += x[ord[t]] - x[i];
now[1] += y[ord[t]] - y[i];
t = t%n + 1;
if(ord[t] == i)t = t%n + 1;
}
ans += (double)now[1] * (x[nj] - x[i]) - (double)now[0] * (y[nj] - y[i]);
}
}
printf("%.12f",ans/n/(n-1)/(n-2));
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1352 KB |
Output is correct |
2 |
Correct |
0 ms |
1352 KB |
Output is correct |
3 |
Correct |
0 ms |
1352 KB |
Output is correct |
4 |
Correct |
0 ms |
1352 KB |
Output is correct |
5 |
Correct |
0 ms |
1352 KB |
Output is correct |
6 |
Correct |
0 ms |
1352 KB |
Output is correct |
7 |
Correct |
0 ms |
1352 KB |
Output is correct |
8 |
Correct |
0 ms |
1352 KB |
Output is correct |
9 |
Correct |
0 ms |
1352 KB |
Output is correct |
10 |
Correct |
0 ms |
1352 KB |
Output is correct |
11 |
Correct |
156 ms |
1352 KB |
Output is correct |
12 |
Correct |
296 ms |
1352 KB |
Output is correct |
13 |
Correct |
184 ms |
1352 KB |
Output is correct |
14 |
Correct |
780 ms |
1352 KB |
Output is correct |
15 |
Correct |
76 ms |
1352 KB |
Output is correct |
16 |
Correct |
752 ms |
1352 KB |
Output is correct |
17 |
Correct |
44 ms |
1352 KB |
Output is correct |
18 |
Correct |
120 ms |
1352 KB |
Output is correct |
19 |
Correct |
196 ms |
1352 KB |
Output is correct |
20 |
Correct |
0 ms |
1352 KB |
Output is correct |
21 |
Correct |
860 ms |
1352 KB |
Output is correct |
22 |
Correct |
856 ms |
1352 KB |
Output is correct |
23 |
Correct |
856 ms |
1352 KB |
Output is correct |
24 |
Correct |
860 ms |
1352 KB |
Output is correct |
25 |
Correct |
864 ms |
1352 KB |
Output is correct |
26 |
Correct |
856 ms |
1352 KB |
Output is correct |
27 |
Correct |
860 ms |
1352 KB |
Output is correct |
28 |
Correct |
860 ms |
1352 KB |
Output is correct |
29 |
Correct |
860 ms |
1352 KB |
Output is correct |
30 |
Correct |
860 ms |
1352 KB |
Output is correct |
31 |
Incorrect |
0 ms |
1352 KB |
Output isn't correct |