Cod sursa(job #1835786)

Utilizator mjmilan11Mujdar Milan mjmilan11 Data 27 decembrie 2016 13:58:45
Problema Triplete Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <iostream>
#include <fstream>
#include <vector>
#include <bitset>
using namespace std;
ifstream fin("triplete.in");
ofstream fout("triplete.out");

bitset <4097> fnd[4097];
vector <int> ls[4097];

int n,m,x,y,i,j,nr,k;

int main()
{
    fin >> n >> m;
    while(m--)
    {
        fin >> x >> y;
        ls[x].push_back(y);
        ls[y].push_back(x);
        fnd[x][y]=fnd[y][x]=1;
    }
    for(i=1;i<=n;i++)
    {
        for(j=0;j<ls[i].size();j++)
        {
            for(k=0;k<ls[ls[i][j]].size();k++)
            {
                if(fnd[i][ls[ls[i][j]][k]]==1) nr++;
            }
        }
    }
    fout << nr/6;
    return 0;
}