Submission #8983

# Submission time Handle Problem Language Result Execution time Memory
8983 2014-09-27T10:11:40 Z ainta Wall construction (kriii2_WA) C++
4 / 4
0 ms 1116 KB
#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 time Memory Grader output
1 Correct 0 ms 1116 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 0 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1116 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 0 ms 1116 KB Output is correct
6 Correct 0 ms 1116 KB Output is correct
7 Correct 0 ms 1116 KB Output is correct
8 Correct 0 ms 1116 KB Output is correct
9 Correct 0 ms 1116 KB Output is correct
10 Correct 0 ms 1116 KB Output is correct
11 Correct 0 ms 1116 KB Output is correct
12 Correct 0 ms 1116 KB Output is correct
13 Correct 0 ms 1116 KB Output is correct
14 Correct 0 ms 1116 KB Output is correct
15 Correct 0 ms 1116 KB Output is correct
16 Correct 0 ms 1116 KB Output is correct
17 Correct 0 ms 1116 KB Output is correct
18 Correct 0 ms 1116 KB Output is correct
19 Correct 0 ms 1116 KB Output is correct
20 Correct 0 ms 1116 KB Output is correct