/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 1ms 540.0 KiB
#3 Wrong Answer 1ms 540.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

lld triangle(lld x1, lld y1, lld x2, lld y2, lld x3, lld y3) {
    return (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2.0;
}

void solve() {
    int n;
    cin >> n;
    vi a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    int x, y;
    cin >> x >> y;
    lld sum1 = 0, sum2 = 0;
    for (int i = 0; i < n; i++) {
        sum1 += a[i] * b[(i + 1) % n];
        sum2 += b[i] * a[(i + 1) % n];
    }
    lld poly_area = abs(sum1 - sum2) / 2.0;
    lld triangle_area = 0.0;
    for (int i = 0; i < n; i++) {
        int x1 = a[i], y1 = b[i];
        int x2 = a[(i + 1) % n], y2 = b[(i + 1) % n];
        int x3 = x, y3 = y;
        triangle_area += triangle(x1, y1, x2, y2, x3, y3);
    }
    if (triangle_area == poly_area) {
        cout << "YES" << '\n';
    } else {
        cout << "NO" << '\n';
    }
}

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-13 15:16:37
Judged At
2024-12-13 15:16:37
Judged By
Score
0
Total Time
1ms
Peak Memory
540.0 KiB