/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 1ms 768.0 KiB
#3 Wrong Answer 1ms 556.0 KiB
#4 Accepted 1ms 540.0 KiB
#5 Accepted 1ms 488.0 KiB
#6 Wrong Answer 1ms 772.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);
	}

};
vector<pt> point;

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;
	//sort(point.begin(), point.end());
	double area = get();

	point.push_back(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 18:29:06
Judged At
2024-12-14 18:29:06
Judged By
Score
12
Total Time
1ms
Peak Memory
772.0 KiB