Cod sursa(job #785577)

Utilizator danalex97Dan H Alexandru danalex97 Data 9 septembrie 2012 13:50:02
Problema Regiuni Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <fstream>
#include <vector>

using namespace std;

const int Hsize = 31789;
const int Hsexion = 11;
const int Nmax = 1010 ;

int a[Nmax],b[Nmax],c[Nmax];
int N,M,A,B,Sol;

vector< short > Hash;

ifstream F("regiuni.in");
ofstream G("regiuni.out");

int main()
{
	F>>N>>M;
	for (int i=1;i<=N;++i)
		F>>a[i]>>b[i]>>c[i];
	
	Hash.push_back( Hsize+1 );
	for (int i=1;i<=M;++i)
	{
		int x,y;
		F>>x>>y;
		
		A=0;
		for (int j=1;j<=N;++j)
			A=( A*Hsexion+( a[j]*x+b[j]*y+c[j] > 0 ) ) % Hsize ;
		
		Hash.push_back( A );
	}
	sort(Hash.begin(),Hash.end());
	
	for (int i=1;i<=M;++i)
		if ( Hash[i]!=Hash[i-1] ) ++Sol;
	
	G<<Sol<<'\n';
}