Cod sursa(job #474541)

Utilizator andrei.dAndrei Diaconeasa andrei.d Data 4 august 2010 00:25:19
Problema Regiuni Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.04 kb
#include <cstdio>
#include <algorithm>

using namespace std;

#define file_in "regiuni.in"
#define file_out "regiuni.out"

#define nmax (1<<10)

int n,m;
struct d1
{
	int x,y;
}
pct[nmax];
struct d2
{
	int a,b,c;
}
dr[nmax];
int h[nmax];


void citire()
{
	freopen(file_in,"r",stdin);
	freopen(file_out,"w",stdout);
	
	int i;
	
	scanf("%d %d", &n, &m);
	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", &pct[i].x, &pct[i].y);
	}
}

#define mod 1000000007

void add(int x)
{
	int put=1;
	h[x]=0;
	for (int i=1;i<=n;++i)
	{
		int ecuatie=pct[x].x*dr[i].a+pct[x].y*dr[i].b+dr[i].c;
		if (ecuatie>0)
			h[x]+=put;
		put<<=1;
		if (h[x]>=mod)
			h[x]%=mod;
		if (put>=mod)
			put%=mod;
	}
}

void solve()
{
	int i,nr=1;
	for (i=1;i<=m;++i)
		  add(i);
	sort(h+1,h+m+1);
	for (i=2;i<=m;++i)
		 if (h[i]!=h[i-1]) nr++;
	printf("%d", nr);
}

int main()
{
	citire();
	solve();
	
	fclose(stdin);
	fclose(stdout);
	
	return 0;
	
}