Cod sursa(job #785617)
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
const int Hsize = 31789;
const int Hsexion = 5;
const int Hsexion2 = 7;
const int Nmax = 1010 ;
short a[Nmax],b[Nmax],c[Nmax];
pair<short,short> Hash[Nmax];
int N,M,A,B,Sol;
int main()
{
FILE *f = fopen("regiuni.in", "r");
fscanf(f, "%d %d", &N, &M);
for (int i=1;i<=N;++i)
fscanf(f, "%d %d %d", &a[i], &b[i] ,&c[i]);
for (int i=1;i<=M;++i)
{
int x,y;
fscanf(f, "%d %d", &x, &y);
A=B=0;
for (int j=1;j<=N;++j)
A=( A*Hsexion+( int(a[j])*x+int(b[j])*y+int(c[j]) > 0 ) ) % Hsize ,
B=( B*Hsexion2+( int(a[j])*x+int(b[j])*y+int(c[j]) > 0 ) ) % Hsize ;
Hash[i]= make_pair(short(A),short(B));
}
sort(Hash+1,Hash+M+1);
for (int i=1;i<=M;++i)
if ( Hash[i]!=Hash[i-1] ) ++Sol;
fprintf(fopen("regiuni.out", "w"), "%d\n" , Sol );
}