Pagini recente » Cod sursa (job #2551842) | Cod sursa (job #2613920) | Cod sursa (job #670413) | Cod sursa (job #1717994) | Cod sursa (job #40335)
Cod sursa(job #40335)
#include<stdio.h>
#define Nmax 1001
int huge mat[Nmax][Nmax];
int p,i,viz[Nmax],k,gasit,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;
}