Pagini recente » Cod sursa (job #3225475) | Cod sursa (job #1572492)
#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;
}