Submission #8960

# Submission time Handle Problem Language Result Execution time Memory
8960 2014-09-27T04:08:30 Z tncks0121 Wall construction (kriii2_WA) C++14
Compilation error
0 ms 0 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;

Compilation message

WA.cpp: In function 'int main()':
WA.cpp:67:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
WA.cpp:73:13: error: expected '}' at end of input
WA.cpp:50:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
WA.cpp:52:44: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]