Cod sursa(job #2798921)

Utilizator VladPislaruPislaru Vlad Rares VladPislaru Data 12 noiembrie 2021 09:32:29
Problema Regiuni Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.8 kb
#include <bits/stdc++.h>
#define P 100002223
using namespace std;

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

int n , m;
struct Dreapta
{
    int a, b ,c;
};
Dreapta D[1005];
unordered_map <int,int> fr;

int main()
{
    int i;
    fin >> n >> m;
    for (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;
        }
        fr[nr]++;
    }
    int cnt = 0;
    for (auto j : fr)
        if (j.second > 0)
            cnt++;
    fout << cnt << "\n";
    return 0;
}