/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 1ms 332.0 KiB
#3 Wrong Answer 2ms 492.0 KiB

Code

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

#define ll long long
#define bug(a) cout << #a << " : " << a << endl;



struct pt{
	ll x, y;
	pt(){
		x = 0;
		y = 0;
	}
	pt(ll x, ll y) : x(x), y(y){

	}

	pt operator - (const pt &a) const {
		return pt(x - a.x, y - a.y);
	}
	pt operator * (const ll a) const {
		return pt(x * a, y * a);
	}
	friend pt operator * (const ll &a, const pt &b){
		return pt(a * b.x, a * b.y);
	}
double norm2() { return x * x + y * y; }
};

bool half(pt p) {
    return p.y > 0.0 || (p.y == 0.0 && p.x < 0.0);
}
inline ll cross(pt p1, pt p2){
	return ((p1.x * p2.y ) - (p1.y * p2.x));
}
void polar_sort(vector<pt> &v, pt o) { // sort points in counterclockwise with respect to point o
    sort(v.begin(), v.end(), [&](pt a,pt b) {
        return make_tuple(half(a - o), 0.0, (a - o).norm2()) < make_tuple(half(b - o), cross(a - o, b - o), (b - o).norm2());
    });
}
void polar_sort(vector<pt> &v) { // sort points in counterclockwise
    sort(v.begin(), v.end(), [](pt a,pt b) {
        return make_tuple(half(a), 0.0, a.norm2()) < make_tuple(half(b), cross(a, b), b.norm2());
    });
}
vector<pt> point;


ll get(){

	ll sum1 = 0, sum2 = 0;
	int n = point.size();
	
	for(int i = 0; i < n; i++){
		sum1+= cross(point[i],point[(i+1)%n]);
	}

	ll ans = fabs(sum1);
	//cout << ans << endl;
	return ans;

}

void solve(){
	int n;	cin >> n;

	for(int i = 1; i <= n; i++){
		int x, y;	cin >> x >> y;
		pt p;
		p.x = x; p.y = y;
		point.push_back(p);
	}

	pair<ll,ll> p1;
	cin >> p1.first >> p1.second;
	pt p11;
	p11.x = p1.first;
	p11.y = p1.second;
	polar_sort(point);
	double area = get();

	point.push_back(p11);
    polar_sort(point,p11);

	double area_upd = get();
	//cout << area_upd << " " << area << endl;
	
	if ( area_upd > area ) {
		cout << "NO" << '\n';
	}
	else {
		cout << "YES" << '\n';
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int tc = 1, cs = 0;
	// cin >> tc;

	while(tc--){
		//cout << "Case # " << ++cs << ": " ;
		solve();
	}

}

Information

Submit By
Type
Submission
Problem
P1145 Nobita's Love for Shizuka
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-14 19:48:04
Judged At
2024-12-14 19:48:04
Judged By
Score
0
Total Time
2ms
Peak Memory
540.0 KiB