QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#751920 | #7906. Almost Convex | guodong | WA | 254ms | 5928kb | C++17 | 1.9kb | 2024-11-15 21:17:12 | 2024-11-15 21:17:13 |
Judging History
answer
#include <bits/stdc++.h>
#define For(i,a,b) for(int i = a; i <= b; ++i)
#define int long long
using namespace std;
const int N = 100200;
int q[N];
struct P{
int x,y;
}a[N];
bool cmp(P a,P b){
if(a.x == b.x)
return a.y < b.y;
return a.x < b.x;
}
signed main()
{
int A,B,C,D,r = 0,t;
ios::sync_with_stdio(false);
#ifdef NICEGUODONG
freopen("data.in","r",stdin);
ios::sync_with_stdio(true);
#endif
A = C = 1e18;
B = D = -A;
int n;
cin >> n;
For(i,1,n){
cin >> a[i].x >> a[i].y;
A = min(A,a[i].x);
B = max(B,a[i].x);
C = min(C,a[i].y);
D = max(D,a[i].y);
}
sort(a + 1, a + n + 1,cmp);
t = 0;
For(i,1,n)
if(!t || a[i].y > r)
r = a[i].y,q[++t] =i;
for(int i = q[r = t] + 1; i <= n; q[++t] = i++)
while(t > r && a[i].y >= a[q[t]].y)
t--;
vector<int> Mark(n + 1);
For(i,1,t){
Mark[q[i]] = 1;
}
t = 0;
For(i,1,n)
if(!t || a[i].y < r)
r = a[i].y,q[++t] =i;
int i;
for(i = q[r = t] + 1,i=q[t] +1; i <= n; q[++t] = i++)
while(t > r && a[i].y <= a[q[t]].y)
t--;
int ans = 1; For(i,1,t){
Mark[q[i]] = 1;
}
for(int i = 1; i <= n; ++i){
vector<pair<double,int>> p;
if(Mark[i]) continue;
for(int j = 1; j <= n; ++j){
if(i == j) continue;
p.push_back(make_pair(atan2(a[j].y - a[i].y,a[j].x - a[i].x),j));
}
sort(p.begin(),p.end(),[&](auto a,auto b){return a.first < b.first;});
if(p.size() == 0) continue;
for(int i = 0;i < (int)p.size(); ++i)
if(Mark[p[i].second] && Mark[p[(i + 1) % p.size()].second]){
ans++;
}
}
cout << ans << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5928kb
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: 3984kb
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: 3620kb
input:
3 0 0 3 0 0 3
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 4008kb
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: 1ms
memory: 5808kb
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: 254ms
memory: 4020kb
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:
10959
result:
wrong answer 1st numbers differ - expected: '718', found: '10959'