forked from marioyc/Online-Judge-Solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2002 - Squares.cpp
47 lines (34 loc) · 1.12 KB
/
2002 - Squares.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
#include <cstdio>
#include <set>
#include <map>
using namespace std;
int main(){
int n;
int x[1000],y[1000];
set< pair<int, int> > S;
while(true){
scanf("%d",&n);
if(n == 0) break;
S.clear();
for(int i = 0;i < n;++i){
scanf("%d %d",&x[i],&y[i]);
S.insert(make_pair(x[i],y[i]));
}
int ans = 0;
for(int i = 0;i < n;++i){
for(int j = i + 1;j < n;++j){
int vx = x[j] - x[i];
int vy = y[j] - y[i];
int x1 = 2 * x[i] + vx - vy,y1 = 2 * y[i] + vy + vx;
int x2 = 2 * x[i] + vx + vy,y2 = 2 * y[i] + vy - vx;
if(x1 % 2 == 0 && y1 % 2 == 0 && y1 % 2 == 0 && y2 % 2 == 0){
x1 /= 2; y1 /= 2;
x2 /= 2; y2 /= 2;
if(S.find(make_pair(x1,y1)) != S.end() && S.find(make_pair(x2,y2)) != S.end()) ++ans;
}
}
}
printf("%d\n",ans / 2);
}
return 0;
}