Cod sursa(job #2281030)

Utilizator PredescuSebastianIonPredescu Sebastian Ion PredescuSebastianIon Data 11 noiembrie 2018 15:35:17
Problema Regiuni Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.87 kb
#include <fstream>
#include <algorithm>

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;
            }
            else
            {
                v[i]=v[i]*2;
            }
        }
    }
    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;
}