Cod sursa(job #2761027)

Utilizator VladCaloVlad Calomfirescu VladCalo Data 30 iunie 2021 10:42:39
Problema Patrate 3 Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.99 kb
//
//  main.cpp
//  patrate3
//
//  Created by Vlad Calomfirescu on 14.05.2021.
//


#include <fstream>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;

ifstream fin ("patrate3.in");
ofstream fout ("patrate3.out");
set < pair < int, int >>p;

int
verif (pair < int, int >a, pair < int, int >b)
{
  int x, y;
  if (a == b)
    {
      return 0;
    }
  x = b.first - a.first; //dist dintre 2 pct oarecare //pe oy
  y = a.second - b.second; //pe ox
  return (p.find ({a.first + x, a.second + y}) != p.end () &&
          p.find ({b.first + x, b.second + y}) != p.end ());
}
// p.end=este in interiorul lui p sau nu
int
citeste () // citim si eliminam virgula din numar
{
  double val;
  fin >> val;
  return round (val * 10000);
};

int
main ()
{
  int n, i, rez = 0;
  fin >> n;
  for (i = n; i >= 0; i--)
    {
      p.insert ( {citeste (), citeste ()} );
    }
for (auto i:p)
    {
    for (auto j:p)
    {
      rez += verif (i, j);
    }
    }
  fout << rez / 4 << '\n';
    return 0;}