QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#333244 | #7906. Almost Convex | lhzawa | WA | 1ms | 3900kb | C++14 | 2.0kb | 2024-02-19 19:06:28 | 2024-02-19 19:06:28 |
Judging History
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'