Cod sursa(job #1099270)

Utilizator CosminRusuCosmin Rusu CosminRusu Data 5 februarie 2014 18:31:54
Problema Regiuni Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.08 kb
/// moving to stdio
#include <stdio.h>
#include <vector>

using namespace std;

vector <short> a, b, c;
vector <int> Hash;
vector <int> Hash2;
short N, M;
short Ans;
short x, y;

int main() {
    freopen("regiuni.in", "r", stdin);
    freopen("regiuni.out", "w", stdout);

    scanf("%hd %hd", &N, &M);

    a.reserve(N);
    b.reserve(N);
    c.reserve(N);
    Hash.reserve(M);
    Hash2.reserve(M);

    for(short i = 0 ; i < N ; ++ i)
        scanf("%hd %hd %hd", &a[i], &b[i], &c[i]);

    for(short i = 0 ; i < M ; ++ i) {
        scanf("%hd %hd", &x, &y);
        for(int j = 0 ; j < N ; ++ j) {
            bool sign = ((a[j] * x + b[j] * y + c[j]) > 0);
            Hash[i] = ((Hash[i] * 2) + sign) % 100007;
            Hash2[i] = ((Hash2[i] * 2) + sign) % 100021;
        }
    }

    for(short i = 0 ; i < M ; ++ i) {
        bool alone = 1;
        for(short j = 0 ; j < i && alone ; ++ j)
            if(Hash[i] == Hash[j] && Hash2[i] == Hash2[j])
                alone = 0;
        Ans += alone;
    }
    printf("%hd\n", Ans);
    return 0;
}