/ 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;

int main()
{
    int n, m;
    cin >> n;
    m = n;

    int x_min = INT_MAX, x_max = INT_MIN;
    int y_min = INT_MAX, y_max = INT_MIN;
    vector<pair<int, int>> v;
    while (m--)
    {
        int x, y;
        cin >> x >> y;
        v.push_back({x, y});
        x_min = min(x, x_min);
        x_max = max(x, x_max);
        y_min = min(y, y_min);
        y_max = max(y, y_max);
    }
    int x, y;
    cin >> x >> y;

    // for(int i = 0; i < n; i++) {
    //     if((v[i].first == x && v[i+ 1].first == x) || (v[i].second == y && v[i+ 1].second == y)){
    //         cout << "YES" << endl;
    //         return 0;
    //     }
    // }

    // int area = 9;
    // for (int i = 0; i < n - 1; i++)
    // {
    //     area = (v[i].first * y + x * v[i + 1].second + v[i + 1].first * v[i].second) - (x * v[i].second + v[i + 1].first * y + v[i].first * v[i + 1].second);
    //     if (area == 0)
    //     {
    //         cout << "YES" << endl;
    //         return 0;
    //     }
    // }

    double slope1, slope2;
    for (int i = 0; i < n - 1; i++)
    {

        if ((x - v[i].first) == 0)
        {
            slope1 = (x - v[i].first) / (y - v[i].second);
        }
        else
        {
            slope1 = (y - v[i].second) / (x - v[i].first);
        }

        if ((v[i + 1].first - x) == 0)
        {
            slope2 = (v[i + 1].first - x) / (v[i + 1].second - y);
        }
        else
        {
            slope2 = (v[i + 1].second - y) / (v[i + 1].first - x);
        }

        // cout << slope1 << endl;
        // cout << slope2 << endl;

        if (slope1 == slope2)
        {
            cout << "YES" << endl;
            return 0;
        }
    }

    int flag = 0;
    for (auto &i : v)
    {

        if (i.first == x && i.second == y)
        {
            cout << "YES" << endl;
            return 0;
        }
    }

    if ((x > x_min && x < x_max) && (y > y_min && y < y_max))
    {
        cout << "YES" << endl;
    }
    else if ((x_max == x_min && x == x_min) || (y_max == y_min && y == y_min))
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

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 06:35:02
Judged At
2024-12-09 06:35:02
Judged By
Score
0
Total Time
1ms
Peak Memory
540.0 KiB