Cod sursa(job #38910)

Utilizator wazupPricop Mircea wazup Data 26 martie 2007 11:25:47
Problema Regiuni Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.7 kb
#include <fstream.h>
#include <string.h>
struct dr { short a,b,c; };
dr drepte[1005];
char grupe[1005][1005],aux[1005];
int k,x,y,gas;
int n,m,i,j,nr;
int main()
{
ifstream fin("regiuni.in");
ofstream fout("regiuni.out");
fin>>n>>m;
for (i=0;i<n;i++)
 fin>>drepte[i].a>>drepte[i].b>>drepte[i].c;
for (i=0;i<m;i++)
   {  fin>>x>>y;
      j=0;
      while (aux[j]) aux[j++]=0;
      nr=0;
      for (j=0;j<n;j++)
	 if (drepte[j].a*x+drepte[j].b*y+drepte[j].c>0)
	    aux[nr++]='1';
	 else
	    aux[nr++]='0';
      gas=0;
      for (j=0;j<k;j++)
	 if (strcmp(aux,grupe[j])==0)
	   {gas=1;
	    break;
	    }
      if (gas==0)
	strcpy(grupe[k++],aux);
   }
fout<<k<<'\n';
return 0;
}