Cod sursa(job #1099239)

Utilizator CosminRusuCosmin Rusu CosminRusu Data 5 februarie 2014 18:06:05
Problema Regiuni Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.85 kb
#include <fstream>
#include <vector>

using namespace std;

ifstream fin("regiuni.in");
ofstream fout("regiuni.out");

int main() {
    short N, M;
    fin >> N >> M;
    vector <short> a(N), b(N), c(N);
    vector <short> Hash(M);
    for(short i = 0 ; i < N ; ++ i)
        fin >> a[i] >> b[i] >> c[i];
    for(short i = 0 ; i < M ; ++ i) {
        short x, y;
        fin >> x >> y;
        for(short j = 0 ; j < N ; ++ j) {
            bool sign = ((a[j] * x + b[j] * y + c[j]) > 0);
            Hash[i] = ((Hash[i] << 1) + sign) % 30005;
        }
    }
    short Ans = 0;
    for(short i = 0 ; i < M ; ++ i) {
        bool alone = true;
        for(short j = 0 ; j < i && alone ; ++ j)
            alone ^= (Hash[i] == Hash[j]);
        Ans += alone;
    }
    fout << Ans << '\n';
    fin.close();
    fout.close();
    return 0;
}