Cod sursa(job #2281035)

Utilizator PredescuSebastianIonPredescu Sebastian Ion PredescuSebastianIon Data 11 noiembrie 2018 15:38:31
Problema Regiuni Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.09 kb
#include <fstream>
#include <algorithm>
#define mod 1323456201

using namespace std;
ifstream f("regiuni.in");
ofstream g("regiuni.out");
struct dreapta
{
    int a,b,c;
} a[1001];
struct punct
{
    int x,y;
} b[1001];
int m,n,i,j,sol;
long long v[1001];
int main()
{
    f>>n>>m;
    for(i=1;i<=n;i++)
    {
        f>>a[i].a>>a[i].b>>a[i].c;
    }
    for(i=1;i<=m;i++)
    {
        f>>b[i].x>>b[i].y;
    }
    for(i=1;i<=m;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(a[j].a*b[i].x+a[j].b*b[i].y+a[j].c>0)
            {
                v[i]=v[i]*2+1;
                if(v[i]>mod)
                {
                    v[i]-=mod;
                }
            }
            else
            {
                v[i]=v[i]*2;
                if(v[i]>mod)
                {
                    v[i]-=mod;
                }
            }
        }
    }
    sort(v,v+m+1);
    sol=0;
    long long aux;
    for(i=1;i<=m;)
    {
        aux=v[i];
        for(;v[i]==aux && i<=m;i++);
        sol++;
    }
    g<<sol<<'\n';
    return 0;
}