// towers.cpp : Defines the entry point for the console application. // #include #include #include using namespace std; struct pt { int x, y; pt(int x_ = 0, int y_ = 0) : x(x_), y(y_) {} }; bool operator <(const pt& l, const pt& r) { return l.x < r.x || l.x == r.x && l.y < r.y; } set pts; void dump_pts() { for (set::iterator i(pts.begin()), e(pts.end()); i != e; i++) { cout << i->x << ", " << i->y << endl; } } int calc_pts() { int c = 0; for (set::iterator i(pts.begin()), e(pts.end()); i != e; i++) { bool uf = true; for(set::iterator j(pts.begin()); uf && j != i; j++) { int dx = i->x - j->x; int dy = i->y - j->y; if ( dx > 0 && dy > 0 || dx == 0 && dy > 0 || dx > 0 && dy == 0) uf = false; } if (uf) c++; } return c; } int main(int argc, char* argv[]) { ifstream in; in.open("towers.in"); ofstream out; out.open("towers.out"); int N; in >> N; for (int i = 0; i < N; i++) { int a, x, y; in >> a >> x >> y; if (a == 1) pts.insert(pt(x, y)); else pts.erase(pt(x, y)); //dump_pts(); cout << endl; out << calc_pts() << endl; } out.close(); return 0; }