/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 1ms 516.0 KiB
#3 Accepted 1ms 556.0 KiB
#4 Wrong Answer 1ms 328.0 KiB
#5 Accepted 2ms 528.0 KiB
#6 Accepted 1ms 540.0 KiB
#7 Accepted 1ms 540.0 KiB
#8 Wrong Answer 2ms 332.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double lld;
typedef unsigned long long int ull;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pi;
typedef pair<char, ll> pci;
typedef vector<pi> vii;
typedef map<ll, ll> mi;
typedef map<char, ll> mci;
typedef set<ll> seti;
typedef set<char> setc;
typedef unordered_set<ll> useti;
typedef unordered_set<char> usetc;
 
#define sz size()
#define ins insert
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define nl << "\n";
#define NO cout << "NO" nl
#define YES cout << "YES" nl
#define all(x) x.begin(), x.end()
#define db(x) cout << #x << " = " << x nl
#define input(x) for (auto &a : x) cin >> a;
#define view(x) cout << #x << ": " nl for (auto &a : x) {cout << a << " ";} cout nl
#define viewp(x) cout << #x << ": " nl for (auto &a : x) {cout << "{" << a.first << ", " << a.second << "} " nl} cout nl
 
void solve(){
	ll n;
	cin >> n;
	vii p;
	for (int i = 0; i < n; i++) {
		ll x, y;
		cin >> x >> y;
		p.pb({x, y});
	}
	p.pb(p[0]);
	ll x2, y2;
	cin >> x2 >> y2;
	lld total = 0, total2 = 0;
	for (ll i = 0; i < n; i++) {
		total += (0.5 * p[i].first * p[i + 1].second);
		total -= (0.5 * p[i + 1].first * p[i].second);
	}
	for (ll i = 1; i <= n; i++) {
		ll x1 = p[i - 1].first, y1 = p[i - 1].second;
		ll x3 = p[i].first, y3 = p[i].second;
		total2 += 0.5 * abs(x1 * (y2 - y3) - y1 * (x2 - x3) + (x2 * y3 - x3 * y2));
	}
	for (ll i = 1; i <= n; i++) {
		ll x1 = p[i - 1].first, y1 = p[i - 1].second;
		ll x3 = p[i].first, y3 = p[i].second;
		lld dist1 = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 -  y2));
		lld dist2 = sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 -  y3));
		lld dist3 = sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 -  y3));
		if (dist1 + dist2 == dist3) {
			NO
			return;
		}
	}
	if (total == total2) {
		YES
	} else {
		NO
	}
}

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	cout.tie(nullptr);
	ll t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1145 Nobita's Love for Shizuka
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-12 16:46:21
Judged At
2024-12-12 16:46:21
Judged By
Score
20
Total Time
2ms
Peak Memory
556.0 KiB