#include #include using namespace std; struct point { int x,y; }; struct line { point p,q; }; point operator - (point a, point b) { point c; c.x = a.x - b.x; c.y = a.y - b.y; return c; } int operator * (point a, point b) { int c = a.x * b.y - b.x * a.y; return c == 0 ? 0 : c / abs(c); } bool intersect(line a, line b) { if (a.p.x == b.p.x && a.p.y == b.p.y) { return false; } if (((b.p-a.p)*(a.q-a.p)) * ((b.q-a.p)*(a.q-a.p)) > 0) return false; if (((a.p-b.p)*(b.q-b.p)) * ((a.q-b.p)*(b.q-b.p)) > 0) return false; return true; } vector state; vector> conn; bool possible(int n, int s) { if (state[n] != -1) { return state[n] == s; } state[n] = s; for (int i : conn[n]) { if (!possible(i, 1-s)) { return false; } } return true; } int main() { int numwells, numpipes; cin >> numwells >> numpipes; vector wells(numwells); for (int i=0; i> wells[i].x >> wells[i].y; } vector pipes(numpipes); for (int i=0; i> well >> pipes[i].q.x >> pipes[i].q.y; pipes[i].p = wells[well-1]; } conn = vector>(numpipes); for (int i=0; i(numpipes, -1); for (int i=0; i