Cod sursa(job #2751158)

Utilizator VladCaloVlad Calomfirescu VladCalo Data 14 mai 2021 14:01:37
Problema Patrate 3 Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.96 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;
    }
  y = b.first - a.first;
  x = a.second - b.second;
  return (p.find (
           {
           a.first + x, a.second + y}
      ) != p.end () && p.find (
                    {
                    b.first + x, b.second + y}
      ) != p.end ());
}

int
citeste ()
{
  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;}