Cod sursa(job #2368292)

Utilizator lucametehauDart Monkey lucametehau Data 5 martie 2019 15:13:32
Problema Regiuni Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.01 kb
#include <fstream>
#include <vector>

using namespace std;

ifstream cin ("regiuni.in");
ofstream cout ("regiuni.out");

struct Cf {
  int a, b, c;
};

struct Punct {
  int x, y;
};

int n, m, g, lst;

Cf v[1005];
Punct p[1005];
vector <Punct> s[16005];

bool susDreapta(Punct p, Cf d) {
  return (p.x * d.a + p.y * d.b + d.c > 0);
}

void divGrup(vector <Punct> gp, Cf d) {
  bool ok1 = 0, ok2 = 0;
  for(auto i : gp) {
    if(susDreapta(i, d)) {
      if(!ok1)
        g++, ok1 = 1;
      s[g].push_back(i);
    } else {
      if(!ok2)
        g++, ok2 = 1;
      s[g].push_back(i);
    }
  }
}

int main() {
  cin >> n >> m;
  for(int i = 1; i <= n; i++)
    cin >> v[i].a >> v[i].b >> v[i].c;
  g = lst = 1;
  for(int i = 1; i <= m; i++) {
    cin >> p[i].x >> p[i].y;
    s[1].push_back(p[i]);
  }
  for(int i = 1; i <= n; i++) {
    int g2 = g;
    for(int j = lst; j <= g2; j++)
      divGrup(s[j], v[i]);
    lst = g2 + 1;
  }
  cout << g - lst + 1;
  return 0;
}