QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#333239#7906. Almost ConvexlhzawaWA 15ms3912kbC++142.0kb2024-02-19 19:00:522024-02-19 19:00:54

Judging History

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

  • [2024-02-19 19:00:54]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:3912kb
  • [2024-02-19 19:00:52]
  • 提交

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, long double> R[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;
    int cnt = 1;
    for (int i = 2; i <= m; i++) {
        int K = 0;
        for (int j = 1; j <= n; j++) ! vis[j] && (R[++K] = {phi(a[j] - a[b[i]]), phi(a[j] - a[b[i - 1]])}, 1);
        std::sort(R + 1, R + K + 1, [&](const auto &x, const auto &y) {return x.fi > y.fi;});
        long double mn = R[1].se;
        cnt++;
        for (int j = 2; j <= K; j++) R[j].se <= mn && (mn = R[j].se, cnt++);
    }
    printf("%d\n", cnt);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3912kb

input:

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

output:

9

result:

ok 1 number(s): "9"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

5
4 0
0 0
2 1
3 3
3 1

output:

5

result:

ok 1 number(s): "5"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

3
0 0
3 0
0 3

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

6
0 0
3 0
3 2
0 2
1 1
2 1

output:

7

result:

ok 1 number(s): "7"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

4
0 0
0 3
3 0
3 3

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: -100
Wrong Answer
time: 15ms
memory: 3896kb

input:

2000
86166 617851
383354 -277127
844986 386868
-577988 453392
-341125 -386775
-543914 -210860
-429613 606701
-343534 893727
841399 339305
446761 -327040
-218558 -907983
787284 361823
950395 287044
-351577 -843823
-198755 138512
-306560 -483261
-487474 -857400
885637 -240518
-297576 603522
-748283 33...

output:

1053

result:

wrong answer 1st numbers differ - expected: '718', found: '1053'