Cod sursa(job #40332)

Utilizator lost_anBlanaru Adina lost_an Data 27 martie 2007 12:55:36
Problema Regiuni Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.08 kb
#include<stdio.h>
#define Nmax 100
int p,viz[Nmax],k,gasit,mat[Nmax][Nmax],i,n,m,j,ec;
struct drepte
{
int a,b,c;
};
struct puncte
{
int x,y;
};
drepte dr[Nmax];
puncte pc[Nmax];


int  main()
{
freopen("regiuni.in","r",stdin);
freopen("regiuni.out","w",stdout);
scanf("%d%d",&n,&m);
//n drepte si m puncte
for (i=1;i<=n;i++)
      scanf("%d%d%d",&dr[i].a,&dr[i].b,&dr[i].c);
for (i=1;i<=m;i++)
      scanf("%d%d",&pc[i].x,&pc[i].y);
for (i=1;i<=n;i++)
      for(j=1;j<=m;j++)
	  {
	  ec=dr[i].a * pc[j].x+ dr[i].b * pc[j].y + dr[i].c;
	  if (ec>0)
		mat[i][j]=1;
	     else mat[i][j]=0;
	  }

p=1;
for (i=1;i<=n;i++,p++)
       {
       for (j=i+1;j<=n;j++)
	   if(viz[j]==0)
	   {
	   for (k=1,gasit=0;(k<=m)&&(gasit==0);k++)
	       if (mat[i][k]!=mat[j][k])
			     gasit=1;
	   if (gasit==0)
		      {
		      mat[j][0]=mat[i][j]=p;
		      viz[j]=1;
		      }
	   }
      if(gasit==1)
	   for (k=i+1,gasit=0;(k<=n)&&(gasit==0);k++)
			if (viz[i]==1)
				 gasit=1;
	    if(gasit==0)  mat[i][0]=p;
      }

p--;
printf("%d\n",p);

return 0;
}