Cod sursa(job #2798923)

Utilizator robertanechita1Roberta Nechita robertanechita1 Data 12 noiembrie 2021 09:33:12
Problema Regiuni Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.75 kb
#include <bits/stdc++.h>
#define P 100002223

using namespace std;

ifstream fin("regiuni.in");
ofstream fout("regiuni.out");

int n, m;

struct D
{
    int a, b, c;
}d[1005];
unordered_map<int, int> M;



int main()
{
    fin >> n >> m;
    for(int i =1; i <= n; i++)
        fin >> d[i].a >> d[i].b >> d[i].c;
    for(int i = 1; i <= m; i++)
    {
        int x, y, nr = 0;
        fin >> x >> y;
        for(int j = 1; j <= n; j++)
        {
            if((d[j].a*x + d[j].b*y + d[j].c) < 0)
                nr = nr*2;
            else nr = nr*2 + 1;
            nr = nr % P;
        }
        M[nr]++;
    }
    int nrG = 0;
    for(auto w : M)
        if(w.second > 0)
            nrG++;
    fout << nrG;
    return 0;
}