-
Notifications
You must be signed in to change notification settings - Fork 34
/
1058-Parallelogram-Counting.cpp
88 lines (57 loc) · 1.07 KB
/
1058-Parallelogram-Counting.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <iostream>
#include <stdio.h>
#include <map>
#include <utility>
#include <vector>
#include <algorithm>
#define pii pair <int, int>
using namespace std;
vector < pii > v;
vector < pii > m;
int main()
{
int t;
int x;
int y;
int n;
scanf("%d", &t);
for (int cs = 1; cs <= t; cs++) {
scanf("%d", &n);
m.clear();
v.clear();
pii temp;
pii p1;
pii p2;
int ans;
int top;
ans = 0;
for (int i = 0; i < n; i++) {
scanf("%d", &temp.first);
scanf("%d", &temp.second);
v.push_back(temp);
}
for (int i = 0; i < v.size(); i++) {
for (int j = i + 1; j < v.size(); j++) {
p1 = v[i];
p2 = v[j];
x = v[i].first + v[j].first;
y = v[i].second + v[j].second;
temp.first = x;
temp.second = y;
m.push_back(temp);
}
}
sort(m.begin(), m.end());
top = 0;
for (int i = 1; i < m.size(); i++) {
if((m[i].first == m[i-1].first) and (m[i].second == m[i-1].second)) {
top++;
}
else {
ans = ans + (top * (top + 1)) / 2;
top = 0;
}
}
printf("Case %d: %d\n",cs, ans);
}
}