Submission #8983

#TimeUsernameProblemLanguageResultExecution timeMemory
8983aintaWall construction (kriii2_WA)C++98
4 / 4
0 ms1116 KiB
#pragma warning(disable:4996) #include<stdio.h> #include<math.h> #include<algorithm> #define PI 3.14159265359 using namespace std; int n, R, st[1010], top, P[1010], cnt; double Res; struct point{ int x, y; bool operator <(const point &p)const{ return x != p.x ? x < p.x : y < p.y; } }w[1010]; int ccw(point a, point b, point c){ return (b.x - a.x)*(c.y - a.y) - (b.y - a.y)*(c.x - a.x); } double dist(point a, point b){ return sqrt(1.0 * (b.x - a.x)*(b.x - a.x) + (b.y - a.y)*(b.y - a.y)); } int main() { int i; scanf("%d%d", &n, &R); for (i = 0; i < n; i++){ scanf("%d%d", &w[i].x, &w[i].y); } sort(w, w + n); st[++top] = 0; for (i = 1; i < n; i++){ while (top > 1 && ccw(w[st[top - 1]], w[st[top]], w[i]) >= 0)top--; st[++top] = i; } for (i = 1; i < top; i++)P[++cnt] = st[i]; top = 0; st[++top] = 0; for (i = 1; i < n; i++){ while (top > 1 && ccw(w[st[top - 1]], w[st[top]], w[i]) <= 0)top--; st[++top] = i; } for (i = top; i >= 1; i--)P[++cnt] = st[i]; for (i = 1; i < cnt; i++){ Res += dist(w[P[i]], w[P[i + 1]]); } printf("%.10lf\n", Res + 2 * PI * R); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...