Cod sursa(job #1110923)

Utilizator chiriacandrei25Chiriac Andrei chiriacandrei25 Data 18 februarie 2014 14:48:50
Problema Regiuni Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.75 kb
#include <cstdio>
#include <algorithm>
#define P 1299811

using namespace std;

int N,M;
short a[1005],b[1005],c[1005],x[1005],y[1005],t[1005];

int main()
{
    int i,j,cnt=0;
    freopen ("regiuni.in","r",stdin);
    freopen ("regiuni.out","w",stdout);
    scanf("%d%d", &N,&M);
    for(i=1;i<=N;++i)
        scanf("%hd%hd%hd", &a[i],&b[i],&c[i]);
    for(i=1;i<=M;++i)
        scanf("%hd%hd", &x[i],&y[i]);
    for(i=1;i<=N;++i)
        for(j=1;j<=M;++j)
            if(1LL*a[i]*x[j]+1LL*b[i]*y[j]+c[i]>0)
                t[j]=(1LL*t[j]*10+1)%P;
            else
                t[j]=(1LL*t[j]*10+2)%P;
    sort(t+1,t+M+1);
    for(i=1;i<=M;++i)
        if(t[i]!=t[i-1])
            ++cnt;
    printf("%d\n", cnt);
    return 0;
}