Cod sursa(job #2561525)

Utilizator SergiuS3003Sergiu Stancu Nicolae SergiuS3003 Data 28 februarie 2020 21:33:14
Problema Triplete Scor 30
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.66 kb
#include <fstream>
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 = x1;
        v[i].y = y1;

        for ( int j = 1; j <= N; j++ )
            if ( a[j][x1] == 1 && a[j][y1] == 1 )
                nrt++;
    }

    g << nrt;
    return 0;
}