Submission #13848

#TimeUsernameProblemLanguageResultExecution timeMemory
13848gs14004Wall construction (kriii2_WA)C++14
1 / 4
0 ms1244 KiB
#include <cstdio> #include <vector> #include <algorithm> #include <cmath> using namespace std; typedef pair<int,int> pi; vector<pi> v; pi a[1005]; bool 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; return dx1 * dy2 > dy1 * dx2; } bool cmp(pi p, pi q){ return ccw(a[0],p,q); } 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])) { v.pop_back(); } v.push_back(a[i]); } double ret = 4 * asin(1) * r; for (int i=0; i<v.size(); i++) { ret += hypot(a[(i+1)%v.size()].first - a[i].first,a[(i+1)%v.size()].second - a[i].second); } printf("%lf",ret); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...