답안 #8957

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
8957 2014-09-27T03:58:48 Z tncks0121 Wall construction (kriii2_WA) C++14
4 / 4
0 ms 1456 KB
#define _CRT_SECURE_NO_WARNINGS
   
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <deque>
#include <utility>
#include <bitset>
#include <limits.h>
#include <time.h>
   
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef double lf;
typedef unsigned int uint;
typedef long double llf;
typedef pair<int, int> pii;
    
int N, R;
   
struct point {
    ll x, y; lf a;
    point (ll x = 0, ll y = 0): x(x), y(y) { }
    bool operator < (const point &p) const { return fabs(a - p.a) > 1e-8 ? a < p.a : (x != p.x ? x < p.x : y < p.y); }
};
   
point D[1005];
   
ll ccw (point a, point b, point c) {
    return a.x * b.y + b.x * c.y + c.x * a.y
        -  b.x * a.y - c.x * b.y - a.x * c.y;
}
   
vector<point> S;
   
int main() {
   
    scanf("%d%d", &N, &R);
    for(int i = 0; i < N; i++) {
        scanf("%lld%lld", &D[i].x, &D[i].y);
        if(i > 0 && (D[i].x < D[0].x || (D[i].x == D[0].x && D[i].y < D[0].y))) swap(D[0], D[i]);
    }
   
    for(int i = 1; i < N; i++) D[i].a = atan2(D[i].y - D[0].y, D[i].x - D[0].x);
    sort(D+1, D+N);
   
    S.push_back(D[0]);
    S.push_back(D[1]);
    for(int i = 2; i < N; i++) {
        while(S.size() >= 2 && ccw(S[S.size()-2], S[S.size()-1], D[i]) <= 0) S.pop_back();
        S.push_back(D[i]);
    }
   
    lf res = acos(-1) * 2 * R;
    for(int i = 0; i < S.size(); i++) {
        res += hypot(S[i].x - S[(i+1)%S.size()].x, S[i].y - S[(i+1)%S.size()].y);
    }
   
    printf("%.10f", res);
   
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1456 KB Output is correct
2 Correct 0 ms 1456 KB Output is correct
3 Correct 0 ms 1456 KB Output is correct
4 Correct 0 ms 1456 KB Output is correct
5 Correct 0 ms 1456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1456 KB Output is correct
2 Correct 0 ms 1456 KB Output is correct
3 Correct 0 ms 1456 KB Output is correct
4 Correct 0 ms 1456 KB Output is correct
5 Correct 0 ms 1456 KB Output is correct
6 Correct 0 ms 1456 KB Output is correct
7 Correct 0 ms 1456 KB Output is correct
8 Correct 0 ms 1456 KB Output is correct
9 Correct 0 ms 1456 KB Output is correct
10 Correct 0 ms 1456 KB Output is correct
11 Correct 0 ms 1456 KB Output is correct
12 Correct 0 ms 1456 KB Output is correct
13 Correct 0 ms 1456 KB Output is correct
14 Correct 0 ms 1456 KB Output is correct
15 Correct 0 ms 1456 KB Output is correct
16 Correct 0 ms 1456 KB Output is correct
17 Correct 0 ms 1456 KB Output is correct
18 Correct 0 ms 1456 KB Output is correct
19 Correct 0 ms 1456 KB Output is correct
20 Correct 0 ms 1456 KB Output is correct