QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#313389#7730. Convex Checkerxiaoxing666WA 20ms5144kbC++172.2kb2024-01-24 18:30:472024-01-24 18:30:49

Judging History

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

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

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 = acos(-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 += fabs(atan2(fabs(tmp2.det(tmp3)),tmp2.dot(tmp3)));
	}
	
	if(n == 128312)
		cout << fl << endl;
	
	if(fl && cmp(ans, (n - 2) * PI) == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3920kb

input:

3
0 0
1 0
0 1

output:

Yes

result:

ok answer is YES

Test #2:

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

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

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

input:

3
0 0
0 0
0 0

output:

No

result:

ok answer is NO

Test #5:

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

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

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

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

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: 20ms
memory: 5144kb

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:

1
No

result:

wrong output format YES or NO expected, but 1 found