Cod sursa(job #2070133)

Utilizator LeVladzCiuperceanu Vlad LeVladz Data 19 noiembrie 2017 11:42:16
Problema Triplete Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.75 kb
#include <fstream>
#include <vector>
#include <bitset>

using namespace std;

ifstream fin("triplete.in");
ofstream fout("triplete.out");

int n,m,i,j,k,x,y,nr;
bitset<4097> a[4097];
vector<short> L[4097];

int main()
{
    fin >> n >> m;
    for (i=1; i<=m; i++)
    {
        fin >> x >> y;
        if (x > y)
            swap(x, y);
        L[x].push_back(y);
        a[x][y] = 1;
    }
    for (i=1; i<=n; i++)
        for (j=0; j<L[i].size(); j++)
            for (k=0; k<L[i].size(); k++)
            {
                x = L[i][j];
                y = L[i][k];
                if (x > y)
                    swap(x, y);
                if (a[x][y] == 1)
                    nr++;
            }
    fout << nr/2;
    return 0;
}