Cod sursa(job #38130)

Utilizator DITzoneCAdrian Diaconu DITzoneC Data 25 martie 2007 14:56:13
Problema Regiuni Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.86 kb
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

#define nmax 1024
#define f first
#define s second
#define mp make_pair
#define FOR(i,s,d) for(i=(s);i<(d);++i)

pair < pair <int,int> , int > A[nmax];
pair <int,int> P[nmax];
int n,m,sol;
string S[nmax];

int smn(pair < pair<int,int>,int > A,pair <int,int> P)
{
	return A.f.f*P.f+A.f.s*P.s+A.s>0;
}

int main()
{
	int a,b,c,i,j;
	freopen("regiuni.in","r",stdin);
	freopen("regiuni.out","w",stdout);

	scanf("%d %d",&n,&m);
	FOR(i,0,n)
	{
		scanf("%d %d %d",&a,&b,&c);
		A[i]=mp(mp(a,b),c);
	}
	random_shuffle(A,A+n);
	FOR(i,0,m)
	{
		scanf("%d %d",&a,&b);
		P[i]=mp(a,b);		
	}
	random_shuffle(P,P+m);
	FOR(i,0,m) 
	{
		S[i]="";
		FOR(j,0,n)
			S[i]+=(char)(smn(A[j],P[i])+'0');
	}
	sort(S,S+m);
	sol=1;
	FOR(i,1,m)
		if(S[i]!=S[i-1])
			sol++;
	printf("%d\n",sol);
	return 0;
}