Cod sursa(job #2368145)

Utilizator loo_k01Luca Silviu Catalin loo_k01 Data 5 martie 2019 14:14:42
Problema Regiuni Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.57 kb
#include <bits/stdc++.h>
#define prim1 9973
#define prim2 8867

using namespace std;
const int nMax = 1005;

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

struct Triplu
{
    int a, b, c;
} d[nMax];

struct Dublu
{
    int x, y;
} p[nMax], cod[nMax];

int n, m, sol;

void Read()
{
    fin >> m >> n;
    for (int i = 1; i <= m; i++)
        fin >> d[i].a >> d[i].b >> d[i].c;
}

inline bool Semn(Triplu A, int x, int y)
{
    /// Verific pozitia fata de dreapta ax + by + c = 0
    /// a punctului (x, y)
    return ( (A.a * x + A.b * y + A.c) > 0);
}

inline bool CMP(const Dublu A, const Dublu B)
{
    if (A.x == B.x)
        return A.y < B.y;
    return A.x < B.x;
}

void Solve()
{
    int i, j, s1, s2, offset, x, y;
    for (i = 1; i <= n; i++)
    {
        s1 = 0;
        s2 = 0;
        fin >> x >> y;
        for (j = 1; j <= m; j++)
        {
            s1 = s1 * 10;
            s2 = s2 * 10;

            if (Semn(d[j], x, y))
                offset = 2;
            else offset = 1;

            s1 = (s1 + offset) % prim1;
            s2 = (s2 + offset) % prim2;
        }
        cod[i] = {s1, s2};
    }
    int gasit;
    sol = 1;
    for (i = 2; i <= n; i++)
    {
        gasit = 0;
        for (j = 1; j < i && !gasit; j++)
            if (cod[i].x == cod[j].x && cod[i].y == cod[j].y)
                gasit = 1;
        if (gasit == 0)
            sol++;
    }
    fout << sol << "\n";
}

int main()
{
    Read();
    Solve();

    fin.close();
    fout.close();
    return 0;
}