Pagini recente » Cod sursa (job #2747374) | Cod sursa (job #363559) | Cod sursa (job #1698196) | Cod sursa (job #831130) | Cod sursa (job #774261)
Cod sursa(job #774261)
#include <cstdio>
#include <algorithm>
#define MAX 1001
#define P1 11
#define P2 17
#define mod1 31789
#define mod2 27891
using namespace std;
int main() {
int n, m;
pair<int, int> Hash[MAX];
int A[MAX], B[MAX], C[MAX];
int i, j, x, y;
int hash1, hash2;
FILE *f = fopen("regiuni.in", "r");
FILE *g = fopen("regiuni.out", "w");
fscanf(f, "%d %d", &n, &m);
for(i = 1; i <= n; i++) {
fscanf(f, "%d %d %d", &A[i], &B[i], &C[i]);
}
for(i = 1; i <= m; i++) {
fscanf(f, "%d %d", &x, &y);
hash1 = 0, hash2 = 0;
for(j = 1; j <= n; j++) {
hash1 = (hash1 * P1 + (A[j] * x + B[j] * y + C[j] > 0)) % mod1;
hash2 = (hash2 * P2 + (A[j] * x + B[j] * y + C[j] > 0)) % mod2;
}
Hash[i].first = hash1;
Hash[i].second = hash2;
}
sort(Hash + 1, Hash + m + 1);
fprintf(g, "%d", unique(Hash + 1, Hash + m + 1) - Hash - 1);
fclose(f);
fclose(g);
return 0;
}