/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 544.0 KiB
#2 Accepted 2ms 540.0 KiB
#3 Accepted 2ms 500.0 KiB
#4 Wrong Answer 2ms 540.0 KiB
#5 Accepted 2ms 328.0 KiB
#6 Accepted 2ms 444.0 KiB
#7 Accepted 2ms 328.0 KiB
#8 Wrong Answer 2ms 492.0 KiB

Code

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

int area(int a, int b, int c, int d, int e, int f) {
    int val = a * d + c * f + e * b - b * c - d * e - a * f;
    return abs(val);
}

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

    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];

    int xx, yy;
    cin >> xx >> yy;

    int a = 0;

    for (int i = 0; i + 1 < n; i++) {
        a += x[i] * y[i + 1];
    }
    a += x[n - 1] * y[0];

    for (int i = 0; i + 1 < n; i++) {
        a -= y[i] * x[i + 1];
    }

    a -= x[0] * y[n - 1];
    int b = 0;


    for (int i = 0; i + 1 < n; i++) {
        b += area(x[i], y[i], x[i + 1], y[i + 1], xx, yy);
    }

    b += area(x[0], y[0], x[n - 1], y[n - 1], xx, yy);

    if(a == b) cout << "YES\n";
    else cout << "NO\n";

}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t = 1; 
    //cin>>t;
    for(int tc = 1; tc <= t; tc++) {
        // cout<<"Case "<<tc<<":";
        solve();
    }
}

Information

Submit By
Type
Submission
Problem
P1145 Nobita's Love for Shizuka
Contest
LU IUJPC : Sylhet Division 2024
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-09 09:14:51
Judged At
2024-12-09 09:14:51
Judged By
Score
20
Total Time
2ms
Peak Memory
544.0 KiB