Pagini recente » Cod sursa (job #3275532) | Cod sursa (job #393627) | Cod sursa (job #1079318) | Cod sursa (job #1821290) | Cod sursa (job #40607)
Cod sursa(job #40607)
#include <cstdio>
#include <algorithm>
using namespace std;
const char iname[] = "regiuni.in";
const char oname[] = "regiuni.out";
#define MAX_N 1000
struct entry {
unsigned int c[MAX_N / 32 + 2];
short int x;
short int y;
} P[MAX_N];
short int a[MAX_N], b[MAX_N], c[MAX_N];
short int n;
short int m;
short int i;
void read_in(void)
{
scanf("%d %d", & n, & m);
for (i = 0; i < n; ++ i)
scanf("%d %d %d", a + i, b + i, c + i);
for (i = 0; i < m; ++ i)
scanf("%d %d", & P[i].x, & P[i].y);
}
int cmp(entry z, entry w)
{
for (i = 0; i <= (n >> 5) + 1; ++ i)
if (z.c[i] != w.c[i]) return z.c[i] < w.c[i];
return 1;
}
int main(void)
{
freopen(iname, "r", stdin);
read_in();
short int depl;
short int segm;
short int i;
short int j;
for (i = 0; i < n; ++ i) {
depl = i >> 5;
segm = i & 31;
for (j = 0; j < m; ++ j)
if (a[i] * P[j].x + b[i] * P[j].y + c[i] < 0)
P[j].c[depl] |= 1 << segm;
}
sort(P, P + m, cmp);
short int Res = 1;
short int thesame;
for (i = 1; i < m; ++ i) {
thesame = 1;
for (int j = 0; j <= (n >> 5) + 1; ++ j)
if (P[i - 1].c[j] != P[i].c[j])
thesame = 0;
if (thesame == 0)
Res ++;
}
freopen(oname, "w", stdout);
printf("%d\n", Res);
return 0;
}