Pagini recente » Cod sursa (job #744913) | Cod sursa (job #3162178) | Cod sursa (job #2576783) | Cod sursa (job #757225) | Cod sursa (job #842129)
Cod sursa(job #842129)
#include <cstdio>
#define N 1000
#define k1 666019
#define k2 660013
using namespace std;
int a[N],b[N],c[N],hash1[N],hash2[N];
int main() {
int n,m,i,j,x,y,key1,key2,groups = 0;
FILE *f = fopen("regiuni.in","r");
FILE *g = fopen("regiuni.out","w");
fscanf(f,"%d %d",&n,&m);
for(i = 0; i < n; i++)
fscanf(f,"%d %d %d",&a[i],&b[i],&c[i]);
for(i = 0; i < m; i++) {
fscanf(f,"%d %d",&x,&y);
hash1[i] = 0, hash2[i] = 0;
for(j = 0; j < n; j++) {
hash1[i] = (11 * hash1[i] + (a[j]*x + b[j]*y + c[j] > 0)) % k1;
hash2[i] = (13 * hash2[i] + (a[j]*x + b[j]*y + c[j] > 0)) % k2;
}
}
for(i = 0; i < m; i++) {
for(j = 0; j < i; j++)
if(hash1[i] == hash1[j] && hash2[i] == hash2[j])
break;
if(i == j)
groups++;
}
fprintf(g,"%d",groups);
fclose(f);
fclose(g);
return 0;
}