-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path1058 - Parallelogram Counting.cpp
97 lines (79 loc) · 1.85 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
88
89
90
91
92
93
94
95
96
97
#include <stdio.h>
#include <iostream>
#include <climits>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <vector>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <utility>
#include <queue>
using namespace std;
#define ll int
#define sl(n) scanf("%d", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define plp pair <int, pll >
#define pb push_back
#define ft first
#define sd second
ll x[1010], y[1010];
pll ar[1000010];
bool comp (pll l, pll r)
{
if (l.first < r.first)
return true;
else if (l.first == r.first)
return l.second < r.second;
else return false;
}
int main ()
{
// freopen("inl.txt", "r", stdin);
// freopen("outu.txt", "w", stdout);
// ios_base::sync_with_stdio(0); // no printf/scanf must be present
ll cs, t, i, j, k, z, ans, q, m, n;
sl(t);
for (cs = 1; cs <= t; cs++)
{
sl(n);
for (i = 1; i <= n; i++)
{
sl(x[i]);
sl(y[i]);
}
k = 0;
for (i = 1; i <= n; i++)
{
for (j = i + 1; j <= n; j++)
{
ar[k++] = pll(x[i] + x[j], y[i] + y[j]);
// cout << i << " " << j << " " << x[i] + x[j] << " " << y[i] + y[j] << " " << mp[pll(x[i] + x[j], y[i] + y[j])] << endl;
}
}
ans = 0;
sort(ar, ar + k, comp);
ll c = 1;
for (i = 0; i < k; i++)
{
if (ar[i-1].first == ar[i].first && ar[i-1].second == ar[i].second)
c++;
else
{
ans += c*(c-1)/2;
c = 1;
}
}
ans += c*(c-1)/2;
printf("Case %d: %d\n", cs, ans);
}
return 0;
}