/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 2ms 512.0 KiB
#3 Accepted 1ms 768.0 KiB
#4 Wrong Answer 1ms 376.0 KiB
#5 Accepted 1ms 776.0 KiB
#6 Accepted 1ms 544.0 KiB
#7 Accepted 1ms 664.0 KiB
#8 Wrong Answer 2ms 328.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define nl '\n'
#define f(i,s,n) for(int i = s; i < n; i++)
// #define int long long

int getSign(int x1, int y1, int x2, int y2, int x3,int y3){
    int dir = (y2 - y1) * (x3 - x2) - (y3 - y2) * (x2 - x1);
    if(dir > 0)return 1;
    if(dir < 0)return 2;
    if(dir == 0)return 0;
}

void solve(){
    int n;cin>>n;
    vector<pair<int, int> > v;
    for(int i = 0; i < n; i++){
        int x,y;cin>>x>>y;
        v.push_back({x, y});
    }
    int nx, ny;cin>>nx>>ny;
    int hobe = getSign(nx, ny, v[0].first, v[0].second, v[1].first, v[1].second);
    if(hobe == 0){cout<<"NO"<<nl;return;}
    for(int i = 0; i < n; i++){
        int tmp = getSign(nx, ny, v[i].first, v[i].second, v[(i + 1) % n].first, v[(i + 1) % n].second);
        // cout<<tmp<<nl;
        if(tmp != hobe){cout<<"NO"<<nl;return;}
    }
    cout<<"YES"<<nl;
}

signed main() {
   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
   int T = 1;
//    cin>>T;
   for(int tc = 1; tc <= T; 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 08:08:04
Judged At
2024-12-09 08:08:04
Judged By
Score
20
Total Time
2ms
Peak Memory
776.0 KiB