Advertisement
Saleh127

Light oj(LO) 1058

Mar 27th, 2021
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10.  
  11. test
  12. {
  13.  
  14. ll n,m,i,j,k=0,l=0;
  15.  
  16. cin>>n;
  17.  
  18. ll x[n+5],y[n+5];
  19.  
  20. cout<<"Case "<<cs<<": ";
  21.  
  22. for(i=0;i<n;i++)
  23. {
  24. cin>>x[i]>>y[i];
  25. }
  26.  
  27. vector<pair<double,double> >ans;
  28.  
  29. for(i=0;i<n;i++)
  30. {
  31. for(j=i+1;j<n;j++)
  32. {
  33. double x1=(x[i]+x[j])/2.00;
  34. double y1=(y[i]+y[j])/2.00;
  35. ans.push_back({x1,y1});
  36. }
  37. }
  38.  
  39. sort(ans.begin(),ans.end());
  40.  
  41. for(i=0;i<ans.size()-1;i++)
  42. {
  43. if(ans[i]==ans[i+1]) k++;
  44. else
  45. {
  46. l+=(k*(k-1)/2);
  47. k=1;
  48. }
  49. }
  50.  
  51. if(k) l+=(k*(k-1)/2);
  52. cout<<l<<endl;
  53. }
  54.  
  55. return 0;
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement