QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#239028 | #7730. Convex Checker | yuxx | TL | 1ms | 7928kb | C++14 | 2.7kb | 2023-11-04 18:09:42 | 2023-11-04 18:09:43 |
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-04 18:09:42]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
const double eps=1e-7;
int n;
struct point {
double x, y;
point () {}
point (double a, double b) : x (a), y (b) {}
bool operator<(const point &a)const{
if(a.x==x)
{
return a.y>y;
}
return a.x>x;
}
point operator - (const point &b) {
return point (x - b.x, y - b.y);
}
};
point p[N], sp[N];
point er[N];
int cmp (double x) {
if (fabs (x) < eps) return 0;
return x > 0 ? 1 : -1;
}
double dis (point a, point b) {
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double cp (point a, point b) {
return a.x * b.y - a.y * b.x;
}
int Andrew () {
sort(p+1,p+n+1);
int len=0;
for (int i=1;i<=n;i++){
while(len>1&&cmp(cp(sp[len]-sp[len-1],p[i]-sp[len-1]))<=0)
{
len--;
}
sp[++len]=p[i];
}
int k=len;
for(int i=n-1;i>=1;i--)
{
while(len>k&&cmp(cp(sp[len]-sp[len-1],p[i]-sp[len-1]))<=0)
{
len--;
}
sp[++len]=p[i];
}
return len;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>p[i].x>>p[i].y;
er[i]=p[i];
}
int t=Andrew();
reverse(er+1,er+n+1);
for(int i=1;i<t;i++)
{
sp[i+t-1]=sp[i];
}
if(n!=t-1)
{
// flag=1;
cout<<"No";
return 0;
}
// for(int i=1;i<=n;i++)
// {
// cout<<er[i].x<<" "<<er[i].y<<endl;
// }
int flag1=0;
int flag2=0;
for(int i=1;i<=n+1;i++)
{
if(er[1].x==sp[i].x and er[1].y==sp[i].y)
{
for(int j=1;j<=n;j++)
{
//// cout<<er[j].x<<" "<<er[j].y<<" "<<sp[i+j-1].x<<" "<<sp[i+j-1].y<<endl;
if(er[j].x!=sp[i+j-1].x or er[j].y!=sp[i+j-1].y)
{
flag1=1;
// cout<<j<<" "<<i;
break;
}
}
break;
}
}
reverse(er+1,er+n+1);
for(int i=1;i<=n+1;i++)
{
if(er[1].x==sp[i].x and er[1].y==sp[i].y)
{
for(int j=1;j<=n;j++)
{
if(er[j].x!=sp[i+j-1].x or er[j].y!=sp[i+j-1].y)
{
flag2=1;
//cout<<j<<" "<<i;
break;
}
}
break;
}
}
if(flag1 and flag2)
{
cout<<"No";
}
else
{
cout<<"Yes";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5928kb
input:
3 0 0 1 0 0 1
output:
Yes
result:
ok answer is YES
Test #2:
score: 0
Accepted
time: 1ms
memory: 7928kb
input:
4 0 0 0 1 1 1 1 0
output:
Yes
result:
ok answer is YES
Test #3:
score: 0
Accepted
time: 1ms
memory: 5916kb
input:
4 0 0 0 3 1 2 1 1
output:
Yes
result:
ok answer is YES
Test #4:
score: 0
Accepted
time: 1ms
memory: 7832kb
input:
3 0 0 0 0 0 0
output:
No
result:
ok answer is NO
Test #5:
score: 0
Accepted
time: 1ms
memory: 5928kb
input:
5 1 0 4 1 0 1 2 0 3 2
output:
No
result:
ok answer is NO
Test #6:
score: 0
Accepted
time: 1ms
memory: 5796kb
input:
5 0 0 1000000000 0 1000000000 500000000 1000000000 1000000000 0 1000000000
output:
No
result:
ok answer is NO
Test #7:
score: 0
Accepted
time: 1ms
memory: 7904kb
input:
5 0 0 1000000000 0 1000000000 499999999 1000000000 1000000000 0 1000000000
output:
No
result:
ok answer is NO
Test #8:
score: 0
Accepted
time: 1ms
memory: 7848kb
input:
5 0 0 999999999 0 1000000000 50000000 999999999 1000000000 0 1000000000
output:
Yes
result:
ok answer is YES
Test #9:
score: -100
Time Limit Exceeded
input:
128312 5578014 410408218 5585076 410404717 5588011 410403262 5588473 410403033 5589740 410402405 5593295 410400643 5593751 410400417 5597248 410398684 5598935 410397848 5600618 410397014 5605185 410394751 5610514 410392111 5614281 410390245 5617263 410388768 5621142 410386847 5630840 410382045 56310...