Pagini recente » Cod sursa (job #663039) | Cod sursa (job #2749749) | Cod sursa (job #736643) | Cod sursa (job #1488227) | Cod sursa (job #1280009)
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
struct Ecuatie {
short int a, b, c;
};
struct Punct {
short int x, y;
int regiune;
Punct (int x, int y) {
this->x = x;
this->y = y;
this->regiune = 0;
}
};
const int NMAX = 1000 + 1;
const int MOD = 12998111;
int n, m;
//Ecuatie dreapta[NMAX];
std::vector <Punct> punct;
void citeste() {
//ifstream f ("regiuni.in");
freopen("regiuni.in", "r", stdin);
//f >> n >> m;
scanf("%d", &n);
scanf("%d", &m);
short int a, b, c;
punct.push_back(Punct(0, 0));
for (int i = 1; i <= n; i++) {
scanf("%hd", &a);
scanf("%hd", &b);
scanf("%hd", &c);
}
for (int i = 1; i <= m; i++) {
scanf("%hd", &a);
scanf("%hd", &b);
punct.push_back(Punct(a, b));
}
}
inline bool comp(Punct a, Punct b) {
return a.regiune < b.regiune;
}
void rezolva() {
int rez;
Ecuatie dreapta;
freopen("regiuni.in", "r", stdin);
scanf("%d", &n);
scanf("%d", &m);
for (int i = 1; i <= n; i++) {
scanf("%hd", &dreapta.a);
scanf("%hd", &dreapta.b);
scanf("%hd", &dreapta.c);
for (int j = 1; j <= m; j++) {
rez = dreapta.a * punct[j].x + dreapta.b * punct[j].y + dreapta.c;
if (rez < 0) punct[j].regiune = ((punct[j].regiune) * 10 + 1) % MOD;
else punct[j].regiune = ((punct[j].regiune) * 10 + 2) % MOD;
}
}
}
void numara() {
freopen("regiuni.out", "w", stdout);
int sol = 1;
for (int i = 2; i <= m; i++)
if (punct[i].regiune != punct[i - 1].regiune) sol++;
printf("%d\n", sol);
}
int main() {
citeste();
rezolva();
sort (punct.begin() + 1, punct.end(), comp);
numara();
return 0;
}