#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#define INF 1600000001
using namespace std;
typedef pair <long long, long long> ll;
ll st=ll(INF, INF);
int ccw(ll a, ll b, ll c){
long long t = a.first*b.second - a.second*b.first;
t += b.first*c.second - b.second*c.first;
t += c.first*a.second - c.second*a.first;
if(t>0) return 1;
else if(t<0) return -1;
else return 0;
}
bool comp(ll a, ll b){
return ccw(st, a, b) < 0;
}
vector <ll> convex_hull( vector <ll> &p ){
vector <ll> re;
sort(p.begin(), p.end());
st = p[0];
stable_sort(p.begin()+1, p.end(), comp);
int l=p.size();
for(int i=0; i<l; i++){
while(re.size()>=2 && ccw(re[re.size()-2], re[re.size()-1], p[i]) >=0 )
re.pop_back();
re.push_back(p[i]);
}
return re;
}
double dist( ll a, ll b ){
return sqrt( (double)(a.first-b.first)*(a.first-b.first) + (a.second-b.second)*(a.second-b.second) );
}
int main(){
vector <ll> p;
long long n, a, b;
double r;
scanf("%lld %lf", &n, &r);
for(int i=0; i<n; i++){
scanf("%lld %lld", &a, &b);
p.push_back(ll(a, b));
}
vector <ll> c = convex_hull( p );
int sz = c.size();
double ans = 2*r*acos(-1.0);
for(int i=0; i<sz; i++)
ans += dist( c[i], c[(i+1)%sz] );
printf("%.13f\n", ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1228 KB |
Output is correct |
2 |
Correct |
0 ms |
1228 KB |
Output is correct |
3 |
Correct |
0 ms |
1228 KB |
Output is correct |
4 |
Correct |
0 ms |
1228 KB |
Output is correct |
5 |
Correct |
0 ms |
1228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1228 KB |
Output is correct |
2 |
Correct |
0 ms |
1228 KB |
Output is correct |
3 |
Correct |
0 ms |
1228 KB |
Output is correct |
4 |
Correct |
0 ms |
1228 KB |
Output is correct |
5 |
Correct |
0 ms |
1228 KB |
Output is correct |
6 |
Correct |
0 ms |
1228 KB |
Output is correct |
7 |
Correct |
0 ms |
1228 KB |
Output is correct |
8 |
Correct |
0 ms |
1228 KB |
Output is correct |
9 |
Correct |
0 ms |
1228 KB |
Output is correct |
10 |
Correct |
0 ms |
1228 KB |
Output is correct |
11 |
Correct |
0 ms |
1228 KB |
Output is correct |
12 |
Correct |
0 ms |
1228 KB |
Output is correct |
13 |
Correct |
0 ms |
1228 KB |
Output is correct |
14 |
Correct |
0 ms |
1228 KB |
Output is correct |
15 |
Correct |
0 ms |
1228 KB |
Output is correct |
16 |
Correct |
0 ms |
1228 KB |
Output is correct |
17 |
Correct |
0 ms |
1228 KB |
Output is correct |
18 |
Correct |
0 ms |
1228 KB |
Output is correct |
19 |
Correct |
0 ms |
1228 KB |
Output is correct |
20 |
Correct |
0 ms |
1228 KB |
Output is correct |