Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #include <iomanip>
- #include <queue>
- #include <cmath>
- #include <algorithm>
- #include <tuple>
- #include <iomanip>
- #include <stdio.h>
- #include <numeric>
- #include <map>
- #include <math.h>
- #define int long long
- #define double double
- #define ull unsigned long long
- #define all(a) a.begin(), a.end()
- #define pii pair<int, int>
- #define pb push_back
- using namespace std;
- pii correct(int x1, int y1, int x2, int y2, int x3, int y3) {
- if ((x2 - x1) * (x3 - x1) + (y2 - y1) * (y3 - y1) == 0) { // cos1 == 0 => 1 = 90 dg
- return {x2 + x3 - x1, y2 + y3 - y1};
- }
- if ((x1 - x2) * (x3 - x2) + (y1 - y2) * (y3 - y2) == 0) {
- return {x1 + x3 - x2, y1 + y3 - y2};
- }
- if ((x1 - x3) * (x2 - x3) + (y1 - y3) * (y2 - y3) == 0) {
- return {x1 + x2 - x3, y1 + y2 - y3};
- }
- return {101, 101};
- }
- bool square(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
- int one, two, three, four;
- one = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
- two = (x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2);
- three = (x4 - x3) * (x4 - x3) + (y4 - y3) * (y4 - y3);
- four = (x1 - x4) * (x1 - x4) + (y1 - y4) * (y1 - y4);
- // cout << one << " " << two << " " << three << " " << four << "\n";
- if (one == two and two == three and three == four and four == one) {
- return true;
- }
- return false;
- }
- map<pair<int, int>, int> m;
- signed main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- int n;
- cin >> n;
- vector<pair<int, int>> a(n);
- for (int i = 0; i < n; i++) {
- cin >> a[i].first >> a[i].second;
- m[a[i]] = 1;
- }
- int ans = 0;
- for (int i = 0; i < n - 2; i++) {
- for (int j = i + 1 ; j < n - 1; j++) {
- for (int k = j + 1; k < n; k++) {
- pair<int, int> v = correct(a[i].first, a[i].second, a[j].first, a[j].second, a[k].first, a[k].second);
- if (m[v]) {
- vector<pair<int, int>> q(4);
- q[0] = a[i];
- q[1] = a[j];
- q[2] = a[k];
- q[3] = v;
- sort(all(q));
- reverse(q.begin() + 2, q.end());
- if (square(q[0].first, q[0].second, q[1].first, q[1].second, q[2].first, q[2].second, q[3].first, q[3].second)) {
- ans++;
- }
- }
- }
- }
- }
- cout << ans / 4;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement