Cod sursa(job #1579998)

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

using namespace std;

int n, m;

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

punct d[1005];

set <int> t;

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

int main()
{
    int i, x, y;
    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;
        t.insert(regiune(x, y));
    }
    ofstream fout("regiuni.out");
    fout << t.size() <<"\n";
    fin.close();
    fout.close();
    return 0;
}