Mai intai trebuie sa te autentifici.
Cod sursa(job #2673383)
Utilizator | Data | 16 noiembrie 2020 17:41:27 | |
---|---|---|---|
Problema | Trapez | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.92 kb |
#include <fstream>
using namespace std;
ifstream cin("trapez.in");
ofstream cout("trapex.out");
struct punct {
int x;
int y;
};
struct verificam {
int ok=0;
int dif;
};
int main()
{
int n,maxx=INT_MIN,maxy=INT_MIN;
punct v[999];
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> v[i].x >> v[i].y;
if (v[i].x > maxx)
maxx = v[i].x;
if (v[i].y > maxy)
maxy = v[i].y;
}
verificam a[1001], b[1001];
for (int i = 0; i < n-2; i++)
for(int j=i+1;j<n;j++)
{
if (v[i].x == v[j].x and v[i].y != v[j].y)
{
a[i].ok++;
a[i].dif = abs(v[i].y - v[j].y);
}
if (v[i].y == v[j].y and v[i].x != v[j].x)
{
b[i].ok++;
b[i].dif = abs(v[i].x - v[j].x);
}
}
int raspuns = 0;
for (int i = 0; i < max(maxy,maxx); i++)
for(int j=0;j<max(maxy,maxx);j++)
{
if(a[i].ok>0&&b[j].ok>0)
{
if (a[i].dif != b[j].dif)
raspuns++;
}
}
cout << raspuns/2;
}