/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Wrong Answer 1ms 544.0 KiB
#3 Wrong Answer 1ms 540.0 KiB

Code

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

typedef long long int ll;
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 set<ll> seti;

#define sz size()
#define ins insert
#define mp make_pair
#define pb push_back
#define nl << "\n";
#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 << ": "; for (auto a : x) {cout << a << " ";} cout nl
#define viewp(x) cout << #x << ": "; for (auto &a : x) {cout << a.first << " " << a.second nl}

void solve() {
    ll n;
    cin >> n;
    vi a(n + 1), b(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cin >> b[i];
    }
    ll x2, y2;
    cin >> x2 >> y2;
    a[n] = a[0];
    b[n] = b[0];
    long double sum = 0;
    for (ll i = 0, j = 1; i < n, j < n + 1; i++, j++) {
        sum += (a[i] * b[j]);
    }
    for (ll i = 1, j = 0; i < n + 1, j < n; i++, j++) {
        sum -= (a[i] * b[j]);
    }
    sum /= 2.0;
    ll it = 0;
    long double min = 1e9;
    for (ll i = 1; i < a.sz; i++) {
        ll p = (b[i - 1] - b[i]), q = (a[i] - a[i - 1]);
        ll r = (a[i - 1] * b[i]) - (a[i] * b[i - 1]);
        long double dist = (abs(p * x2 + q * y2 + r)) / sqrt(p * p + q * q);
        long double total = (a[i] - a[i - 1]) * (a[i] - a[i - 1]) + (b[i] - b[i - 1]) * (b[i] - a[i - 1]);
        long double dist2 = (a[i] - x2) * (a[i] - x2) + (b[i] - y2) * (b[i] - y2);
        long double dist3 = (x2 - a[i - 1]) * (x2 - a[i - 1]) + (y2 - b[i - 1]) * (y2 - a[i - 1]);
        if (dist2 > total || dist3 > total) continue;
        if (dist < min) {
            min = dist;
            it = i - 1;
        }
    }
    a.ins(a.begin() + it + 1, x2);
    b.ins(b.begin() + it + 1, y2);
    long double sum2 = 0;
    for (ll i = 0, j = 1; i < n + 1, j < n + 2; i++, j++) {
        sum2 += (a[i] * b[j]);
    }
    for (ll i = 1, j = 0; i < n + 2, j < n + 1; i++, j++) {
        sum2 -= (a[i] * b[j]);
    }
    sum2 /= 2.0;
    if (abs(sum2) >= abs(sum)) {
        cout << "NO" nl
    } else {
        cout << "YES" nl
    }
}

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
Contest
LU IUJPC : Sylhet Division 2024
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-09 07:21:04
Judged At
2024-12-09 07:21:04
Judged By
Score
0
Total Time
2ms
Peak Memory
544.0 KiB