Pagini recente » Cod sursa (job #348944) | Cod sursa (job #1292909) | Cod sursa (job #1232689) | Cod sursa (job #278660) | Cod sursa (job #2561506)
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream f ( "triplete.in" );
ofstream g ( "triplete.out" );
bool a[4100][4100];
struct relatii
{
int x, y;
};
relatii v[4100 * 16];
bool cmpx ( relatii a, relatii b )
{
if ( a.x == b.x )
return a.y < b.y;
return a.x < b.x;
}
int main()
{
int x1, y1, N, M, nrt = 0;
f >> N >> M;
for ( int i = 1; i <= M; i++ )
{
f >> x1 >> y1;
a[x1][y1] = a[y1][x1] = 1;
v[i].x = min ( x1, y1 );
v[i].y = max ( y1, x1 );
}
sort ( v + 1, v + M + 1, cmpx );
for ( int i = 1; i <= M; i++ )
{
int l=v[i].x,c=v[i].y;
for(int j=l+1;j<=N;j++)
if(a[j][l]==1&&a[j][c]==1)
nrt++;
}
g<<nrt/2;
return 0;
}