Cod sursa(job #785581)
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
const int Hsize = 31789;
const int Hsexion = 11;
const int Nmax = 1010 ;
short a[Nmax],b[Nmax],c[Nmax];
short Hash[Nmax];
int N,M,A,B,Sol;
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];
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[i]= A;
}
sort(Hash+1,Hash+M+1);
for (int i=1;i<=M;++i)
if ( Hash[i]!=Hash[i-1] ) ++Sol;
G<<Sol<<'\n';
}