Pagini recente » Cod sursa (job #15386) | Cod sursa (job #910806) | Cod sursa (job #54175) | Cod sursa (job #3147718) | Cod sursa (job #1891691)
#include <fstream>
#include <vector>
using namespace std;
ifstream fin ("regiuni.in");
ofstream fout ("regiuni.out");
class dreapta { public : int a, b, c; } N[1010];
class punct { public : int x, y; } M[1010];
int n, m, g = 1;
vector < int > A, V[10010];
bool Pos(punct p, dreapta d)
{
return (d.a * p.x + d.b * p.y + d.c > 0);
}
int main()
{
fin >> n >> m;
for (int i = 1; i <= n; i ++)
{
fin >> N[i].a >> N[i].b >> N[i].c;
}
for (int i = 1; i <= m; i ++)
{
fin >> M[i].x >> M[i].y;
V[g].push_back(i);
}
for (int i = 1; i <= n; i ++)
{
for (int j = 1, jj = g; j <= jj; j ++)
{
if (V[j].size() <= 1) continue;
int a = 0;
for (vector < int > :: iterator it = V[j].begin(); it != V[j].end(); it ++)
{
if (Pos(M[*it], N[i])) A.push_back(*it);
else a ++;
}
if (!A.empty() && a)
{
g ++;
for (vector < int > :: iterator it1 = V[j].begin(), it2 = A.begin(); it1 != V[j].end() && it2 != A.end(); it1 ++)
{
if (*it1 == *it2)
{
swap(*it1, V[j].back());
V[j].pop_back();
V[g].push_back(*it2);
it2 ++;
}
}
}
while (!A.empty()) A.pop_back();
}
}
fout << g << '\n';
fout.close();
return 0;
}