Pagini recente » Rating George Bodea (UtilizatorGB) | Cod sursa (job #1206189) | Cod sursa (job #155259) | Cod sursa (job #3227631) | Cod sursa (job #2368145)
#include <bits/stdc++.h>
#define prim1 9973
#define prim2 8867
using namespace std;
const int nMax = 1005;
ifstream fin("regiuni.in");
ofstream fout("regiuni.out");
struct Triplu
{
int a, b, c;
} d[nMax];
struct Dublu
{
int x, y;
} p[nMax], cod[nMax];
int n, m, sol;
void Read()
{
fin >> m >> n;
for (int i = 1; i <= m; i++)
fin >> d[i].a >> d[i].b >> d[i].c;
}
inline bool Semn(Triplu A, int x, int y)
{
/// Verific pozitia fata de dreapta ax + by + c = 0
/// a punctului (x, y)
return ( (A.a * x + A.b * y + A.c) > 0);
}
inline bool CMP(const Dublu A, const Dublu B)
{
if (A.x == B.x)
return A.y < B.y;
return A.x < B.x;
}
void Solve()
{
int i, j, s1, s2, offset, x, y;
for (i = 1; i <= n; i++)
{
s1 = 0;
s2 = 0;
fin >> x >> y;
for (j = 1; j <= m; j++)
{
s1 = s1 * 10;
s2 = s2 * 10;
if (Semn(d[j], x, y))
offset = 2;
else offset = 1;
s1 = (s1 + offset) % prim1;
s2 = (s2 + offset) % prim2;
}
cod[i] = {s1, s2};
}
int gasit;
sol = 1;
for (i = 2; i <= n; i++)
{
gasit = 0;
for (j = 1; j < i && !gasit; j++)
if (cod[i].x == cod[j].x && cod[i].y == cod[j].y)
gasit = 1;
if (gasit == 0)
sol++;
}
fout << sol << "\n";
}
int main()
{
Read();
Solve();
fin.close();
fout.close();
return 0;
}