Cod sursa(job #1832383)

Utilizator Bodo171Bogdan Pop Bodo171 Data 19 decembrie 2016 21:30:19
Problema Regiuni Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.81 kb
#include <iostream>
#include <fstream>
using namespace std;
const int nmax=1005;
const int mod1=1000000007;
const int mod2=1000000017;
struct hash_code
{
    int m1,m2;
}h[nmax];
int a[nmax],b[nmax],c[nmax];
int n,m,i,reg,x,y,j,ec;
bool ok;
int main()
{
    ifstream f("regiuni.in");
    ofstream g("regiuni.out");
    f>>n>>m;
    for(i=1;i<=n;i++)
        f>>a[i]>>b[i]>>c[i];
    for(i=1;i<=m;i++)
    {
        f>>x>>y;
        for(j=1;j<=n;j++)
        {
            ec=a[j]*x+b[j]*y+c[j];
            h[i].m1*=2,h[i].m2*=2;
            if(ec<0) h[i].m1++,h[i].m2++;
            h[i].m1%=mod1,h[i].m2%=mod2;
        }
        ok=1;
        for(j=1;j<i;j++)
            if(h[i].m1==h[j].m1&&h[i].m2==h[j].m2)
              ok=0;
        if(ok) reg++;
    }
    g<<reg;
    return 0;
}