/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Accepted 1ms 540.0 KiB
#3 Accepted 1ms 540.0 KiB
#4 Accepted 2ms 336.0 KiB
#5 Accepted 1ms 540.0 KiB
#6 Accepted 1ms 556.0 KiB
#7 Accepted 2ms 440.0 KiB
#8 Accepted 1ms 540.0 KiB
#9 Accepted 2ms 552.0 KiB
#10 Accepted 1ms 772.0 KiB
#11 Accepted 1ms 328.0 KiB
#12 Accepted 1ms 816.0 KiB
#13 Accepted 1ms 540.0 KiB
#14 Accepted 1ms 332.0 KiB
#15 Wrong Answer 2ms 492.0 KiB
#16 Accepted 1ms 796.0 KiB
#17 Wrong Answer 2ms 748.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; }

};
inline double cross(pt a, pt b) { return a.x * b.y - a.y * b.x; }

bool half(pt p) {
    return p.y > 0.0 || (p.y == 0.0 && p.x < 0.0);
}
vector<pt> point;
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());
    });
}
// inline ll Cross(pt p1, pt p2){
// 	return ((p1.x * p2.y ) - (p1.y * p2.x));
// }
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);

	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 18:36:07
Judged At
2024-12-14 18:36:07
Judged By
Score
56
Total Time
2ms
Peak Memory
816.0 KiB