QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#331002#7730. Convex CheckerHanghangWA 0ms3740kbC++14725b2024-02-17 21:59:142024-02-17 21:59:14

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 19:27:17]
  • hack成功,自动添加数据
  • (/hack/727)
  • [2024-07-04 19:17:30]
  • hack成功,自动添加数据
  • (/hack/726)
  • [2024-02-17 21:59:14]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3740kb
  • [2024-02-17 21:59:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
ll dcmp(ll x){return x>0?1:x<0?-1:0;}
struct Point{ll x,y;};
typedef Point Vec;
Vec operator +(Vec a,Vec b){return {a.x+b.x,a.y+b.y};}
Vec operator -(Vec a,Vec b){return {a.x-b.x,a.y-b.y};}
ll Cro(Vec a,Vec b){return a.x*b.y-a.y*b.x;}
ll Dot(Vec a,Vec b){return a.x*b.x+a.y*b.y;}
bool PolyShape(Point *p,int n)
{
	p[0]=p[n];p[n+1]=p[1];
	for(int i=1,op=0;i<=n;i++)
	{
		int o=dcmp(Cro(p[i]-p[i-1],p[i+1]-p[i]));
		if(!o)return 0;
		if(!op)op=o;
		else if(op!=o)return 0; 
	}
	return 1;
}
const int N=1e6+3;
int n;
Point p[N];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>p[i].x>>p[i].y;
	puts(PolyShape(p,n)?"Yes":"No");
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3740kb

input:

3
0 0
1 0
0 1

output:

Yes

result:

ok answer is YES

Test #2:

score: 0
Accepted
time: 0ms
memory: 3660kb

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: 3624kb

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: 3740kb

input:

3
0 0
0 0
0 0

output:

No

result:

ok answer is NO

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3736kb

input:

5
1 0
4 1
0 1
2 0
3 2

output:

Yes

result:

wrong answer expected NO, found YES