Pagini recente » Cod sursa (job #3197234) | Cod sursa (job #2821703) | Cod sursa (job #280324) | Cod sursa (job #1109276) | Cod sursa (job #2629904)
#include <cstdio>
#include <vector>
#include <string>
using namespace std;
const int SIZE = 1 << 10;
int pointer = SIZE;
char buffer[SIZE];
char Advance() {
if (pointer == SIZE) {
fread(buffer, 1, SIZE, stdin);
pointer = 0;
}
return buffer[pointer++];
}
int Read() {
int answer = 0;
char ch = Advance();
while (!isdigit(ch)) {
ch = Advance();
}
while (isdigit(ch)) {
answer = answer * 10 + ch - '0';
ch = Advance();
}
return answer;
}
const int N = 1000 + 7;
int m, n, a[N], b[N], c[N], x[N], y[N], cnt = 1;
vector<int> who[N];
bool f(int i, int j) {
return (a[i] * (long long) x[j] + b[i] * (long long) y[j] + c[i] > 0);
}
int main() {
freopen ("regiuni.in", "r", stdin);
freopen ("regiuni.out", "w", stdout);
m = Read();
n = Read();
for (int i = 1; i <= m; i++) {
a[i] = Read();
b[i] = Read();
c[i] = Read();
}
for (int i = 1; i <= n; i++) {
x[i] = Read();
y[i] = Read();
who[1].push_back(i);
}
for (int i = 1; i <= m; i++) {
int cnt2 = cnt;
for (int it = 1; it <= cnt; it++) {
vector<int> a, b;
for (auto &j : who[it]) {
if (f(i, j)) {
a.push_back(j);
} else {
b.push_back(j);
}
}
if (a.empty() || b.empty()) {
continue;
}
who[it] = a;
who[++cnt2] = b;
}
cnt = cnt2;
}
printf("%d\n", cnt);
return 0;
}