fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. ll ary[10000][2];
  5. int caso;
  6. vector<map<ll,ll>> maap;
  7. ll dist(int i,int j){
  8. ll x1,x2,y1,y2;
  9. x1=ary[i][0],x2=ary[j][0];
  10. y1=ary[i][1],y2=ary[j][1];
  11. return (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
  12. }
  13. int main(){
  14. ios_base::sync_with_stdio(false);
  15. cin.tie(0);
  16. cout.tie(0);
  17. cin>>caso;
  18. for(int t=1;t<=caso;t++){
  19. ll n;
  20. cin>>n;
  21. for(int i=0;i<n;i++)
  22. cin>>ary[i][0]>>ary[i][1];
  23.  
  24. maap.clear();
  25. maap.resize(2001);
  26. ll resp=0;
  27. for(int i=0;i<n;i++){
  28. for(int j=i+1;j<n;j++){
  29. ll d=dist(i,j);
  30. maap[i][d]++;
  31. maap[j][d]++;
  32. }
  33. }
  34. for(int i=0;i<n;i++){
  35. for(auto itr : maap[i]){
  36. ll d=itr.second;
  37. resp+=d*(d-1)/2;
  38. }
  39. }
  40. cout<<"Case #"<<t<<": "<<resp<<'\n';
  41. }
  42. return 0;
  43. }
  44.  
Success #stdin #stdout 0s 3616KB
stdin
Standard input is empty
stdout
Standard output is empty