Cod sursa(job #1572492)

Utilizator ionanghelinaIonut Anghelina ionanghelina Data 18 ianuarie 2016 22:33:07
Problema Trapez Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.78 kb
#include<cstdio>
using namespace std;
int n,x[1005],y[1005],v[1005],z[1005],dv,nr,dz,nr1,nro;
int main()
{
    freopen("trapez.in","r",stdin);
    freopen("trapez.out","w",stdout);
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        scanf("%d%d",&x[i],&y[i]);
        bool ok=1;
        for (int j=1;j<=dv;j++)
            if (v[j]==x[i]) ok=0,nro=j;
        if (ok==1)
        {
            v[++dv]=i;
        }
            else nr++,v[nro]=-1;
        ok=1;
        for (int j=1;j<=dz;j++)
            if (z[j]==y[i]) ok=0,nro=j;
        if (ok==1)
        {
            z[++dz]=i;
        }
            else
            {nr1++;
            z[nro]=-1;
            }
    }
    int x2=(nr*(nr-1))/2+(nr1*(nr1-1))/2;
    printf("%d\n",x2);

    return 0;
}