POJ 1113 WALL算法一直错

POJ 1113 WALL 一直 WA,我的代码有什么问题?求解决。


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
double pi = acos(-1.0);

struct point {
    int x, y;
};
point p[1005], s[1005];
int n, l;
double ans = 0;
int xx, yy;
int top = 0;
bool cmp1(point a, point b) {
    if (a.y == b.y) return a.x < b.x;
    return a.y < b.y;
}
bool cmp2(point a, point b) {
    if (atan2((a.y - yy), (a.x - xx)) != atan2((b.y - yy), (b.x - xx)))
        return atan2((a.y - yy), (a.x - xx)) < atan2((b.y - yy), (b.x - xx));
    return a.x < b.x;
}
int cross(point a, point b, point c) {
    return (c.x - a.x) * (b.y - a.y) - (c.y - a.y) * (b.x - a.x);
}
double dis(point a, point b) {
    return sqrt((double)(a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
void graham() {
    xx = p[0].x;
    yy = p[0].y;
    s[0] = p[0];
    sort(p + 1, p + n, cmp2);
    s[1] = p[1];
    top = 1;
    for (int i = 2;i < n;i++) {
        if (top>=1&&cross(s[top - 1], s[top], p[i]) >= 0)
            top--;
        s[++top] = p[i];
    }
}
int main() {
    scanf("%d%d", &n, &l);
    for (int i = 0;i < n;i++) {
        scanf("%d%d", &p[i].x, &p[i].y);
    }
    sort(p, p + n, cmp1);
    graham();
    for (int i = 0;i < top;i++) {
        //cout << dis(s[i], s[i + 1]) << endl;
        ans += dis(s[i], s[i + 1]);
    }
    ans += dis(s[top], s[0]);
    //cout << dis(s[top], s[0]) << endl;
    ans += 2 * pi * l;
    //cout << 2 * pi * l << endl;
    printf("%.0lf\n", ans);
}