Cod sursa(job #1580013)

Utilizator CraiuAndrei Craiu Craiu Data 25 ianuarie 2016 12:42:12
Problema Regiuni Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.2 kb
#include <bits/stdc++.h>
#define P 123457
#define Q 799999

using namespace std;

int n, m;

struct punct
{
    short a, b, c;
};

punct d[1005];

int t[1005], v[1005];

void regiune(int x, int y, int &hp, int &hq)
{
    int i;
    hp = hq = 0;
    for(i = 1; i <= n; i++)
    {
        if(d[i].a * x + d[i].b * y + d[i].c > 0)
        {
            hp = (hp * 10 + 1) % P;
            hq = (hq * 10 + 1) % Q;
        }
        else
        {
            hp = (hp * 10 + 2) % P;
            hq = (hq * 10 + 2) % Q;
        }
    }
}

int main()
{
    int i, x, y, hp, hq, j;
    bool gasit;
    ifstream fin("regiuni.in");
    fin >> n >> m;
    for(i = 1; i <= n; i++)
        fin >> d[i].a >> d[i].b >> d[i].c;
    for(i = 1; i <= m; i++)
    {
        fin >> x >> y;
        regiune(x, y , hp, hq);
        t[i] = hp;
        v[i] = hq;
    }
    x = 0;
    for(i = 1; i <= m; i++)
    {
        gasit = false;
        for(j = i + 1; j <= m; j++)
            if(t[j] == t[i] && v[j] == v[i])
                gasit = true;
        if(!gasit) x++;
    }
    ofstream fout("regiuni.out");
    fout << x <<"\n";
    fin.close();
    fout.close();
    return 0;
}