#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef pair<int,int> pi;
vector<pi> v;
pi a[1005];
int ccw(pi a, pi b, pi c){
int dx1 = b.first - a.first;
int dy1 = b.second - a.second;
int dx2 = c.first - a.first;
int dy2 = c.second - a.second;
if(dx1 * dy2 == dy1 * dx2) return 0;
else return 2 * (dx1 * dy2 > dy1 * dx2) - 1;
}
bool cmp(pi p, pi q){
int t = ccw(a[0],p,q);
if(t == 1) return 1;
else if(t == 0) return hypot(a[0].first - p.first,a[0].second - p.second) > hypot(a[0].first - q.first,a[0].second - q.second);
return 0;
}
int n,r;
int main(){
scanf("%d %d",&n,&r);
for (int i=0; i<n; i++) {
scanf("%d %d",&a[i].first,&a[i].second);
}
swap(a[0],*min_element(a,a+n));
sort(a+1,a+n,cmp);
v.push_back(a[0]);
for (int i=1; i<n; i++) {
while (v.size() >= 2 && ccw(v[v.size()-2],v.back(),a[i]) == -1) {
v.pop_back();
}
v.push_back(a[i]);
}
double ret = 4 * asin(1) * r;
for (int i=0; i<v.size(); i++) {
ret += hypot(v[(i+1)%v.size()].first - v[i].first,v[(i+1)%v.size()].second - v[i].second);
}
printf("%.12lf",ret);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1244 KB |
Output is correct |
2 |
Correct |
0 ms |
1244 KB |
Output is correct |
3 |
Correct |
0 ms |
1244 KB |
Output is correct |
4 |
Correct |
0 ms |
1244 KB |
Output is correct |
5 |
Correct |
0 ms |
1244 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1244 KB |
Output is correct |
2 |
Correct |
0 ms |
1244 KB |
Output is correct |
3 |
Correct |
0 ms |
1244 KB |
Output is correct |
4 |
Correct |
0 ms |
1244 KB |
Output is correct |
5 |
Correct |
0 ms |
1244 KB |
Output is correct |
6 |
Correct |
0 ms |
1244 KB |
Output is correct |
7 |
Correct |
0 ms |
1244 KB |
Output is correct |
8 |
Correct |
0 ms |
1244 KB |
Output is correct |
9 |
Correct |
0 ms |
1244 KB |
Output is correct |
10 |
Correct |
0 ms |
1244 KB |
Output is correct |
11 |
Correct |
0 ms |
1244 KB |
Output is correct |
12 |
Correct |
0 ms |
1244 KB |
Output is correct |
13 |
Correct |
0 ms |
1244 KB |
Output is correct |
14 |
Correct |
0 ms |
1244 KB |
Output is correct |
15 |
Correct |
0 ms |
1244 KB |
Output is correct |
16 |
Correct |
0 ms |
1244 KB |
Output is correct |
17 |
Correct |
0 ms |
1244 KB |
Output is correct |
18 |
Correct |
0 ms |
1244 KB |
Output is correct |
19 |
Correct |
0 ms |
1244 KB |
Output is correct |
20 |
Correct |
0 ms |
1244 KB |
Output is correct |