Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define x first
- #define y second
- using namespace std;
- using Point = pair<int, int>;
- istream &operator >> (istream &in, Point &point) {
- in >> point.x >> point.y;
- return in;
- }
- int solve(const set<Point> &points) {
- int ans = 0;
- set<Point>::const_iterator it1, it2;
- for (it1 = cbegin(points); it1 != cend(points); it1++) {
- it2 = it1;
- advance(it2, 1);
- for (; it2 != cend(points); it2++) {
- if (it1->x == it2->x || it1->y == it2->y) {
- continue;
- }
- const auto &p3 = Point(it1->x, it2->y);
- const auto &p4 = Point(it2->x, it1->y);
- if (points.count(p3) && points.count(p4)) {
- ans++;
- }
- }
- }
- return ans >> 1;
- }
- signed main() {
- int n;
- cin >> n;
- vector<Point> points(n);
- for (auto &point : points) {
- cin >> point;
- }//*/
- cout << "Nr. of rectangles with lines || with Ox, Oy is: ";
- cout << solve(set<Point>(cbegin(points), cend(points))) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement