/ SeriousOJ /

Record Detail

Compile Error

foo.cc:38:34: error: empty character constant
   38 |         if(tmp == 0){cout<<"NO"<<nl;return;}
      |                                  ^~
foo.cc:47:34: error: empty character constant
   47 |         if(cnt % 2){cout<<"YES"<<nl;return;}
      |                                  ^~
foo.cc:52:17: error: empty character constant
   52 |     cout<<"NO"<<nl;
      |                 ^~

Code

#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define nl ''
#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;
}

int interSect(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4){
    int dir1 = getSign(x1, y1, x2, y2, x3, y3);
    int dir2 = getSign(x1, y1, x2, y2, x4, y4);
    int dir3 = getSign(x3, y3, x4, y4, x1, y1);
    int dir4 = getSign(x3, y3, x4, y4, x2, y2);
    // cout<<dir1<<" "<<dir2<<" "<<dir3<<" "<<dir4<<nl;
    if(dir1 != dir2 && dir3 != dir4)return 0;
    else return 1;
}

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 == 0){cout<<"NO"<<nl;return;}
    }
    int frq = 0, nwx = 1e10, nwy = 1e10;
    while(frq < 5){
        int cnt = 0;
        for(int i = 0; i < n; i++){
            cnt += interSect( v[i].first, v[i].second, v[(i + 1) % n].first, v[(i + 1) % n].second, nx, ny, nwx, nwy);
            // cout<<cnt<<nl;
        }
        if(cnt % 2){cout<<"YES"<<nl;return;}
        nwx += 7;
        frq++;
    }
    
    cout<<"NO"<<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 09:43:06
Judged At
2024-12-09 09:43:06
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes