codeforce 660D Number of Parallelograms

时间:2023-03-09 08:27:21
codeforce 660D  Number of Parallelograms

题意:询问多少个矩形。

统计横纵坐标差,放进vector中

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<stack>
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int x[],y[];
vector<pair<int,int> >v;
int main(){
int n;
while(~scanf("%d",&n)){
for(int i=;i<n;i++)
scanf("%d%d",&x[i],&y[i]); for(int i=;i<n;i++){
for(int j=i+;j<n;j++){
//cout<<"~~"<<endl;
int dx=x[i]-x[j];
int dy=y[i]-y[j];
if(dx<||(dx==&&dy<)){
dx=-dx,dy=-dy;
}
v.push_back(make_pair(dx,dy));
}
}
//cout<<"~~"<<endl;
sort(v.begin(),v.end());
//printf("size:%d\n",v.size());
LL cnt=;
LL ans=;
for(int i=;i<(int)v.size()-;i++){
cnt++;
if(v[i+]!=v[i]){
ans+=cnt*(cnt-)/;
cnt=;
}
}
printf("%I64d\n", ans/);
}
return ;
}