QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#313394#7730. Convex Checkerxiaoxing666WA 24ms5232kbC++172.2kb2024-01-24 18:32:582024-01-24 18:32:58

Judging History

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

  • [2024-07-04 19:27:17]
  • hack成功,自动添加数据
  • (/hack/727)
  • [2024-07-04 19:17:30]
  • hack成功,自动添加数据
  • (/hack/726)
  • [2024-01-24 18:32:58]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:5232kb
  • [2024-01-24 18:32:58]
  • 提交

answer

#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

typedef long long db;

const long double EPS = 1e-15;
const long double PI = acosl(-1);

inline int sign(long double a) { return a < -EPS ? -1 : a > EPS; }

inline int cmp(long double a, long double b){ return sign(a-b); }

struct P {
	db x, y;
	P() {}
	P(db _x, db _y) : x(_x), y(_y) {}
	P operator+(P p) { return {x + p.x, y + p.y}; }
	P operator-(P p) { return {x - p.x, y - p.y}; }
	P operator*(db d) { return {x * d, y * d}; }
	P operator/(db d) { return {x / d, y / d}; }
	
	bool operator<(P p) const { 
		int c = cmp(x, p.x);
		if (c) return c == -1;
		return cmp(y, p.y) == -1;
	}
	
	bool operator==(P o) const{
		return cmp(x,o.x) == 0 && cmp(y,o.y) == 0;
	}
	
	db dot(P p) { return x * p.x + y * p.y; }	//点乘
	db det(P p) { return x * p.y - y * p.x; }	//叉乘
	
	db distTo(P p) { return (*this-p).abs(); }
	double alpha() { return atan2(y, x); }
	void read() { cin>>x>>y; }
	void write() {cout<<"("<<x<<","<<y<<")"<<endl;}
	db abs() { return sqrt(abs2());}
	db abs2() { return x * x + y * y; }
	P rot90() { return P(-y,x);}	//旋转90度
	P unit() { return *this/abs(); }
	int quad() const { return sign(y) == 1 || (sign(y) == 0 && sign(x) >= 0); }
};

#define cross(p1,p2,p3) ((p2.x-p1.x)*(p3.y-p1.y)-(p3.x-p1.x)*(p2.y-p1.y))
#define crossOp(p1,p2,p3) sign(cross(p1,p2,p3))		//逆时针正,顺时针负,共线0

int n;
vector<P> p;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		db x, y;
		cin >> x >> y;
		p.push_back({x, y});
	}
	
	int b = sign((p[0] - p[n - 1]).det(p[1] - p[0]));
	
	if(b > 0)
	{
		reverse(p.begin(), p.end());
	}
	
	bool fl = 1;
	double ans = 0;
	
	for(int i = 0; i < n; i++)
	{
		P tmp1 = p[i] - p[(i - 1 + n) % n];
		P tmp2 = p[(i + 1) % n] - p[i];
		P tmp3 = p[(i - 1 + n) % n] - p[i];
		
		if(sign(tmp2.det(tmp1)) <= 0)
		{
			fl = 0;
			break;
		}
		
		if(p[i - 1] == p[i]){
			fl = 0;
			break;
		}
		
		ans += fabsl(atan2l(fabsl(tmp2.det(tmp3)),tmp2.dot(tmp3)));
	}
	
	if(fl && cmp(ans, (n - 2) * PI) == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
	return 0;
}

詳細信息

Test #1:

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

input:

3
0 0
1 0
0 1

output:

Yes

result:

ok answer is YES

Test #2:

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

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

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

input:

3
0 0
0 0
0 0

output:

No

result:

ok answer is NO

Test #5:

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

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: 0ms
memory: 3628kb

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

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: 0ms
memory: 3600kb

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: 24ms
memory: 5232kb

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:

No

result:

wrong answer expected YES, found NO