Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- #include <unordered_set>
- struct Point {
- int x, y;
- Point(int x, int y) : x(x), y(y) {}
- bool operator<(const Point &other) const {
- return x < other.x or x == other.x and y < other.y;
- }
- };
- int main() {
- std::set<Point> points_set;
- int points_amount;
- std::cin >> points_amount;
- for (int index = 0; index < points_amount; ++index) {
- int x, y;
- std::cin >> x >> y;
- points_set.emplace(x, y);
- }
- std::unordered_set<int> x_lines, y_lines;
- auto current_point = points_set.begin();
- auto next_point = std::next(points_set.begin());
- for (; next_point != points_set.end(); ++next_point, ++current_point) {
- if (current_point->x == next_point->x && current_point->y < next_point->y) {
- y_lines.insert(current_point->y + 1);
- } else {
- x_lines.insert(current_point->x + 1);
- }
- }
- std::cout << y_lines.size() + x_lines.size() << "\n";
- for (auto line : y_lines) {
- std::cout << "y " << line << "\n";
- }
- for (auto line : x_lines) {
- std::cout << "x " << line << "\n";
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment