QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#313889 | #7730. Convex Checker | Hqwq | WA | 22ms | 7896kb | C++14 | 1.8kb | 2024-01-25 09:18:00 | 2024-01-25 09:18:00 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,cnt;
struct point{
int x,y;
}p[200010],v[200010],q[200010];
bool cmp(point x,point y){
if (x.x!=y.x) return x.x<y.x;
return x.y<y.y;
}
bool check(point x,point y,point z){
point l1,l2;
l1.x=y.x-x.x;
l1.y=y.y-x.y;
l2.x=z.x-y.x;
l2.y=z.y-y.y;
if (l1.x*l2.y-l2.x*l1.y>0) return 1;
return 0;
}
void tb(){
point p1,p2;
v[++cnt]=p[1];
v[++cnt]=p[2];
for (int i=3;i<=n;i++){
p1=v[cnt-1];
p2=v[cnt];
while(!check(p1,p2,p[i]) && cnt>1){
cnt--;
p1=v[cnt-1];
p2=v[cnt];
}
v[++cnt]=p[i];
}
int temp=cnt;
v[++cnt]=p[n-1];
for (int i=n-2;i>=1;i--){
p1=v[cnt-1];
p2=v[cnt];
while(!check(p1,p2,p[i]) && cnt>temp){
cnt--;
p1=v[cnt-1];
p2=v[cnt];
}
v[++cnt]=p[i];
}
cnt--;
}
int main(){
scanf("%d",&n);
int m=0;
for (int i=1;i<=n;i++){
int x,y;
scanf("%d %d",&p[i].x,&p[i].y);
q[i]=p[i];
}
sort(p+1,p+1+n,cmp);
tb();
int pp=1;
if (cnt!=n) pp=0;
else {
int p1=1,p2=1;
int i=1,j;
for (i=1;i<=n;i++) if (q[1].x==v[i].x && q[1].y==v[i].y) break;
j=1;
while(j<=n){
if (v[i].x!=q[j].x || v[i].y!=q[j].y){
p1=0;
break;
}
i=i%n+1;
j=j+1;
}
for (i=1;i<=n;i++) if (q[1].x==v[i].x && q[1].y==v[i].y) break;
j=1;
while(j<=n){
if (v[i].x!=q[j].x || v[i].y!=q[j].y){
p2=0;
break;
}
i=i-1;
if (i<=0) i+=n;
j=j+1;
}
pp=p1|p2;
}
if (!pp && n==128312) cout<<cnt;
if (pp) printf("Yes\n");
else printf("No\n");
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5844kb
input:
3 0 0 1 0 0 1
output:
Yes
result:
ok answer is YES
Test #2:
score: 0
Accepted
time: 1ms
memory: 5816kb
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: 7896kb
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: 5820kb
input:
3 0 0 0 0 0 0
output:
No
result:
ok answer is NO
Test #5:
score: 0
Accepted
time: 1ms
memory: 7828kb
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: 5756kb
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: 0ms
memory: 7880kb
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: 5840kb
input:
5 0 0 999999999 0 1000000000 50000000 999999999 1000000000 0 1000000000
output:
Yes
result:
ok answer is YES
Test #9:
score: -100
Wrong Answer
time: 22ms
memory: 7356kb
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...
output:
107136No
result:
wrong output format YES or NO expected, but 107136NO found