Cod sursa(job #3234372)

Utilizator alex210046Bratu Alexandru alex210046 Data 9 iunie 2024 09:55:12
Problema Patrate 3 Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.94 kb
#include <iostream>
#include <fstream>
#include <set>
#include <math.h>
using namespace std;
ifstream f ("date.in");
ofstream g ("date.out");
const int eps = 1e5;

struct punct {
    int x, y;
    bool operator < (const punct& a) const {
        if(x != a.x)
            return x < a.x;
        if(x != a.y)
            return y < a.y;
        return 0;
    }
};

inline int rnd(float x) {
    return round(x * eps);
}

set<punct> puncte;

bool exptr(punct a, punct b) {
    int cy = b.x - a.x, cx = a.y - b.y;
    return (puncte.find({a.x + cx, a.x + cy}) != puncte.end() && puncte.find({b.y + cx, b.y + cy}) != puncte.end());
}

int main() {
    int n, rez = 0;
    float a, b;
    f >> n;
    for(int i = 0; i < n; i++) {
        f >> a >> b;
        puncte.insert({rnd(a), rnd(b)});
    }
    for(punct i : puncte)
        for(punct j : puncte)
            if(i.x != j.x && i.y != j.y)
                rez += exptr(i, j);
    g << rez / 4;

    return 0;
}