-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAntipodal.cpp
67 lines (56 loc) · 1.38 KB
/
Antipodal.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <bits/stdc++.h>
using namespace std;
#define pp pair<long long, long long>
#define ll long long
#define PI 3.14159265
double getSlope(pp &a, pp &b)
{
double m1 = atan(1.0 * (a.second - b.second) / (a.first - b.first)) * 180 / PI;
return m1;
}
double getSlopeInv(pp &a, pp &b)
{
double m2 = atan(1.0 * (b.first - a.first) / (a.second - b.second)) * 180 / PI;
return m2;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
pp points[n];
for (int i = 0; i < n; i++)
{
ll x, y;
cin >> x >> y;
points[i] = make_pair(x, y);
}
ll count = 0;
for (int i = 0; i < n; i++)
{
unordered_map<double, ll> m;
for (int j = 0; j < n; j++)
{
if (i == j)
{
continue;
}
double slope = getSlope(points[i], points[j]);
double temp = getSlopeInv(points[i], points[j]);
// double slope =i;
m[slope]++;
if (m.find(temp) != m.end())
{
count+=m[temp];
}
}
}
cout << count << endl;
}
}