QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#275408 | #7906. Almost Convex | democy | WA | 7ms | 4520kb | C++17 | 1.6kb | 2023-12-04 18:02:56 | 2023-12-04 18:02:57 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define LD double
#define LL long long
#define Vector Point
const int N=2e3+5;
int vis[N];
struct Point{
LL x,y;int id;Point(LL X=0,LL Y=0){x=X,y=Y;}
inline Point operator-(const Point &O)const{return Point(x-O.x,y-O.y);}
}P[N],cp[N],B[N],C[N];
inline LL Cro(Vector a,Vector b){return a.x*b.y-a.y*b.x;}
inline bool cmp1(Vector a,Vector b){return a.x==b.x?a.y<b.y:a.x<b.x;};
inline int ConvexHull(Point *P,int n,Point *cp){
sort(P+1,P+n+1,cmp1);
for(int i=1;i<=n;++i)P[i].id=i;
int t=0;
for(int i=1;i<=n;++i){//ÏÂ͹°ü
while(t>1&&Cro(cp[t]-cp[t-1],P[i]-cp[t-1])<=0)--t;
cp[++t]=P[i];
}
int St=t;
for(int i=n-1;i>=1;--i){//ÉÏ͹°ü
while(t>St&&Cro(cp[t]-cp[t-1],P[i]-cp[t-1])<=0)--t;
cp[++t]=P[i];
}
return --t;
}
inline bool cmp2(Vector a,Vector b){return Cro(a,b)>0;};
inline LD calc(Vector a){return atan2(a.y,a.x);}
int n,m,ans=1;
int main(){
// freopen("123.txt","r",stdin);
scanf("%d",&n);
for(int i=1;i<=n;++i)scanf("%lld%lld",&P[i].x,&P[i].y);
int cnt=ConvexHull(P,n,cp);
for(int i=1;i<=cnt;++i)vis[cp[i].id]=1;
for(int i=1;i<=n;++i)if(!vis[i])B[++m]=P[i];
for(int i=1;i<=cnt;++i){
Point a=cp[i],b=cp[i+1];
// printf("(%lld,%lld) <-> (%lld,%lld):\n",a.x,a.y,b.x,b.y);
for(int j=1;j<=m;++j)C[j]=B[j]-a,C[j].id=j;
sort(C+1,C+m+1,cmp2);
// for(int j=1;j<=m;++j)printf("%lld,%lld\n",C[j].x,C[j].y);
LD maxk=-1e9;
for(int j=1;j<=m;++j){
LD tmpk=calc(B[C[j].id]-b);
if(tmpk>=maxk)++ans,maxk=tmpk;
}
}
printf("%d\n",ans);
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 4428kb
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: 4448kb
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: 4156kb
input:
3 0 0 3 0 0 3
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 4444kb
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: 4148kb
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: 7ms
memory: 4520kb
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:
813
result:
wrong answer 1st numbers differ - expected: '718', found: '813'