QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#333244#7906. Almost ConvexlhzawaWA 1ms3900kbC++142.0kb2024-02-19 19:06:282024-02-19 19:06:28

Judging History

你现在查看的是最新测评结果

  • [2024-02-19 19:06:28]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3900kb
  • [2024-02-19 19:06:28]
  • 提交

answer

#include<bits/stdc++.h>
#define fi first
#define se second
using i64 = long long;
struct Point {
    i64 x, y;
    inline Point(i64 x_ = 0, i64 y_ = 0) {x = x_, y = y_;}
};
using Vector = Point;
inline Vector operator + (const Vector &p1, const Vector &p2) {
    return Vector(p1.x + p2.x, p1.y + p2.y);
}
inline Vector operator - (const Vector &p1, const Vector &p2) {
    return Vector(p1.x - p2.x, p1.y - p2.y);
}
inline i64 operator % (const Vector &p1, const Vector &p2) {
    return p1.x * p2.y - p1.y * p2.x;
}
inline long double phi(const Vector &p) {
    return atan2l(p.y, p.x);
}
struct Line {
    Point st, ed;
    inline Line(Point st_, Point ed_) {st = st_, ed = ed_;}
};
using Seg = Line;
inline i64 IsPointOnRight(const Line &l, const Point &p) {
    return (p - l.st) % (l.ed - l.st);
}
const int maxn = 2e3 + 10;
Point a[maxn];
int b[maxn], m;
bool vis[maxn];
std::pair<long double, int> R[maxn];
int nxt[maxn];
int main() {
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%lld%lld", &a[i].x, &a[i].y);
    std::sort(a + 1, a + n + 1, [&](Point x, Point y) {return x.x == y.x ? x.y < y.y : x.x < y.x;});
    for (int i = 1; i <= n; i++) {
        while (m >= 2 && IsPointOnRight(Line(a[b[m - 1]], a[i]), a[b[m]]) < 0) vis[b[m--]] = 0;
        vis[i] = 1, b[++m] = i;
    }
    vis[1] = 0;
    for (int i = n; i; i--) {
        if (vis[i]) continue;
        while (m >= 2 && IsPointOnRight(Line(a[b[m - 1]], a[i]), a[b[m]]) < 0) vis[b[m--]] = 0;
        vis[i] = 1, b[++m] = i;
    }
    if (m == n + 1) return puts("1"), 0;
    for (int i = 1; i <= m; i++) nxt[b[i]] = b[i + 1];
    int cnt = 1;
    for (int i = 1; i <= n; i++) {
        if (vis[i]) continue;
        for (int j = 1; j <= n; j++) R[j] = {j == i ? -1e9 : phi(a[j] - a[i]), j};
        std::sort(R + 1, R + n + 1, [&](const auto &x, const auto &y) {return x.fi < y.fi;});
        for (int j = 2; j < n; j++) cnt += nxt[R[i].se] == R[i + 1].se;
        cnt += nxt[R[n].se] == R[2].se;
    }
    printf("%d\n", cnt);
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3900kb

input:

7
1 4
4 0
2 3
3 1
3 5
0 0
2 4

output:

4

result:

wrong answer 1st numbers differ - expected: '9', found: '4'