QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#276050 | #7906. Almost Convex | KXDdesu | WA | 211ms | 4132kb | C++20 | 1.8kb | 2023-12-05 15:29:55 | 2023-12-05 15:29:56 |
Judging History
answer
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef pair<double, int> PDI;
const int N = 2e3 + 10;
struct point
{
int x, y;
};
point q[N];
int stk[N], top;
bool used[N];
PDI g[N];
point operator- (point a, point b)
{
return {a.x - b.x, a.y - b.y};
}
int cross(point a, point b)
{
return a.x * b.y - a.y * b.x;
}
int area(point a, point b, point c)
{
return cross(b - a, c - a);
}
void perfect()
{
int n;
cin >> n;
for(int i = 1; i <= n; i ++)
cin >> q[i].x >> q[i].y;
sort(q + 1, q + 1 + n, [&](point a, point b)
{
if(a.x !=b.x) return a.x < b.x;
return a.y < b.y;
});
for(int i = 1; i <= n; i ++)
{
while(top >= 2 && area(q[stk[top - 1]], q[stk[top]], q[i]) > 0)
used[stk[top --]] = false;
stk[++ top] = i;
used[i] = true;
}
used[1] = false;
for(int i = n; i >= 1; i --)
{
if(used[i]) continue;
while(top >= 2 && area(q[stk[top - 1]], q[stk[top]], q[i]) > 0)
used[stk[top --]] = false;
stk[++ top] = i;
used[i] = true;
}
int ans = 0;
for(int i = 1; i <= n; i ++)
{
if(used[i]) continue;
int id = 0;
for(int j = 1; j <= n; j ++)
{
if(j == i) continue;
g[++ id] = {atan2(q[j].y - q[i].y, q[j].x - q[i].x), j};
}
sort(g + 1, g + 1 + id, [&](PDI a, PDI b)
{
return a.fi < b.fi;
});
for(int j = 1; j <= id; j ++)
if(used[g[j].se] && used[g[j % id + 1].se]) ans ++;
}
cout << ans + 1 << endl;
}
int main()
{
int T = 1;
while(T --) perfect();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3992kb
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: 3996kb
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: 3712kb
input:
3 0 0 3 0 0 3
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 4000kb
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: 3644kb
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: 211ms
memory: 4132kb
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:
188176
result:
wrong answer 1st numbers differ - expected: '718', found: '188176'