Cod sursa(job #2567702)

Utilizator andreighinea1Ghinea Andrei-Robert andreighinea1 Data 3 martie 2020 18:26:50
Problema Triplete Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <iostream>
#include <fstream>
#include <bitset>
#define nmax 4100
#define mmax 65550

using namespace std;

ifstream f("triplete.in");
ofstream o("triplete.out");

int n,m,i,x,y,sum;
int st[mmax],dr[mmax];
bitset<nmax> a[nmax];

int main()
{
    f >> n >> m;
    for(i=1;i<=m;++i){
        f >> x >> y;
        a[x][y]=1;
        a[y][x]=1;
        st[i]=x;
        dr[i]=y;
    }

    for(i=1;i<=m;++i){
        x=st[i];
        y=dr[i];
        sum+=(a[x]&a[y]).count();
    }
    o << sum/3 << '\n';

    return 0;
}