Cod sursa(job #3168075)

Utilizator LucaMihaiLM10Luca Ilie LucaMihaiLM10 Data 11 noiembrie 2023 15:17:44
Problema Poligon Scor 0
Compilator cpp-64 Status done
Runda Lista lui wefgef Marime 0.88 kb
#include <bits/stdc++.h>

using namespace std;

struct point {
    int x, y;
};

const int MAX_N = 800;
point p[MAX_N];

long long det( point a, point b, point c ) {
    return (long long)(b.x - a.x) * (c.y - a.y) - (long long)(c.x - a.x) * (b.y - a.y);
}

int main() {
    ifstream cin( "poligon.in" );
    ofstream cout( "poligon.out" );
    int n, m;

    cin >> n >> m;
    for ( int i = 0; i < n; i++ )
        cin >> p[i].x >> p[i].y;

    point o = { 0, 0 };
    long long arie = 0;
    for ( int i = 0; i < n; i++ )
        arie += det( o, p[i], p[(i + 1) % n] );
    arie = abs( arie );

    int cnt = 0;
    while ( m-- ) {
        point a;
        cin >> a.x >> a.y;

        long long newArie = 0;
        for ( int i = 0; i < n; i++ )
            newArie += abs( det( a, p[i], p[(i + 1) % n] ) );

        if ( newArie == arie )
            cnt++;
    }

    cout << cnt;

    return 0;
}