Cod sursa(job #2913649)

Utilizator euyoTukanul euyo Data 15 iulie 2022 20:17:06
Problema Patrate 3 Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.78 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin( "patrate3.in" );
ofstream fout( "patrate3.out" );

const int DIM = 1005;

map<pair<double, double>, int> M;

double x[DIM], y[DIM];

int main() {
  int n;

  fin >> n;
  for ( int i = 1; i <= n; ++i ) {
	fin >> x[i] >> y[i];
    ++M[make_pair(x[i], y[i])];
  }
  int cnt = 0;
  for ( int i = 1; i <= n; ++i ) {
	for ( int j = 1; j <= n; ++j ) {
	  if ( i == j ) continue;
	  double xc = (x[i] + x[j]) / 2.0,  yc = (y[i] + y[j]) / 2.0;    
      double xd = (x[i] - x[j]) / 2.0,  yd = (y[i] - y[j]) / 2.0;  
      double x3 = xc - yd, y3 = yc + xd;  
      double x4 = xc + yd, y4 = yc - xd;  
      
	  if ( M.count({x3, y3}) && M.count({x4, y4}) ) {
        ++cnt; 
	  }
	}
  }
  fout << cnt;
  fin.close();
  fout.close();
  return 0;
}