QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#240302 | #7730. Convex Checker | syf0 | WA | 4ms | 16324kb | C++14 | 1.3kb | 2023-11-05 14:24:09 | 2023-11-05 14:24:10 |
Judging History
你现在查看的是最新测评结果
- [2024-07-04 19:27:17]
- hack成功,自动添加数据
- (/hack/727)
- [2024-07-04 19:17:30]
- hack成功,自动添加数据
- (/hack/726)
- [2023-12-08 14:40:48]
- hack成功,自动添加数据
- (//qoj.ac/hack/493)
- [2023-11-07 10:32:52]
- hack成功,自动添加数据
- (//qoj.ac/hack/426)
- [2023-11-07 10:28:41]
- hack成功,自动添加数据
- (//qoj.ac/hack/425)
- [2023-11-05 14:24:09]
- 提交
answer
#include <bits/stdc++.h>
#define int long long
#define double long double
const int N=2e5+5;
using namespace std;
struct point
{
double x,y;
point(double x=0,double y=0):x(x),y(y){}
}a[N],ans[N];
typedef point vectors;
vectors operator+(vectors a,vectors b){return vectors(a.x+b.x,a.y+b.y);}
//Vector+Vector=Vector,point+Vector=point
vectors operator-(point a,point b){return vectors(a.x-b.x,a.y-b.y);}
//point-point=Vector
vectors operator*(vectors a,double p){return vectors(a.x*p,a.y*p);}
//Vector*point=Vector
vectors operator/(vectors a,double p){return vectors(a.x/p,a.y/p);}
//Vector/dig=Vector
bool operator<(const point& a,const point& b){return a.x<b.x||(a.x==b.x&&a.y<b.y);}
//point位置
double cross(vectors a,vectors b){return a.x*b.y-a.y*b.x;}
//Vector叉积
int andrew(point* p,int n,point* cc)
{
sort(p+1,p+n+1);
int s=0;
for(int i=1;i<=n;i++)
{while(s>1&&cross(cc[s-1]-cc[s-2],p[i]-cc[s-2])<=0)s--;cc[s++]=p[i];}
int k=s;
for(int i=n-1;i>=1;i--)
{while(s>k&&cross(cc[s-1]-cc[s-2],p[i]-cc[s-2])<=0)s--;cc[s++]=p[i];}
if(n>1)s--;
return s;
}
int n;
signed main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i].x>>a[i].y;
int len=andrew(a,n,ans);
if(len!=n)cout<<"No\n";
else cout<<"Yes\n";
}
详细
Test #1:
score: 100
Accepted
time: 4ms
memory: 16260kb
input:
3 0 0 1 0 0 1
output:
Yes
result:
ok answer is YES
Test #2:
score: 0
Accepted
time: 4ms
memory: 16324kb
input:
4 0 0 0 1 1 1 1 0
output:
Yes
result:
ok answer is YES
Test #3:
score: 0
Accepted
time: 0ms
memory: 16252kb
input:
4 0 0 0 3 1 2 1 1
output:
Yes
result:
ok answer is YES
Test #4:
score: 0
Accepted
time: 0ms
memory: 16176kb
input:
3 0 0 0 0 0 0
output:
No
result:
ok answer is NO
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 16184kb
input:
5 1 0 4 1 0 1 2 0 3 2
output:
Yes
result:
wrong answer expected NO, found YES