Pagini recente » Cod sursa (job #616139) | Cod sursa (job #1473894) | Borderou de evaluare (job #3178045) | Cod sursa (job #2752639) | Cod sursa (job #40125)
Cod sursa(job #40125)
#include <cstdio>
#include <algorithm>
using namespace std;
#define MAXN 1005
int N, M;
short A[MAXN], B[MAXN], C[MAXN];
short o[MAXN];
unsigned char smn[MAXN][MAXN];
inline void set1( int x, int y ) { smn[x][y >> 3] |= (1 << (y & 7)); }
inline bool semn( short A, short B, short C, int x, int y )
{
int D = ((int)A * x + (int)B * y + (int)C);
if (D > 0) return true;
return false;
}
inline int cmp( short a, short b )
{
for (int i = 0; i < (N + 7) / 8; i++)
if (smn[a][i] != smn[b][i])
return smn[a][i] < smn[b][i];
return 0;
}
inline int eq( short a, short b )
{
for (int i = 0; i < (N + 7) / 8; i++)
if (smn[a][i] != smn[b][i])
return 0;
return 1;
}
int main()
{
freopen("regiuni.in", "rt", stdin);
freopen("regiuni.out", "wt", stdout);
scanf("%d %d", &N, &M);
for (int i = 0; i < N; i++)
scanf("%hd %hd %hd", A + i, B + i, C + i);
for (int i = 0; i < M; i++)
{
int X, Y;
scanf("%d %d", &X, &Y);
for (int j = 0; j < N; j++)
if ( semn( A[j], B[j], C[j], X, Y ) )
set1( i, j );
o[i] = i;
}
sort(o, o + M, cmp);
int nM = unique( o, o + M, cmp ) - o + 1;
printf("%u\n", nM);
return 0;
}