Cod sursa(job #2449164)

Utilizator ezioconnorVlad - Gabriel Iftimescu ezioconnor Data 18 august 2019 14:04:52
Problema Triplete Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.59 kb
#include <fstream>
#include <bitset>

using namespace std;

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

int n, m, rez;
bitset <4100> b[4100], aux;

int main()
{
    int x, y;
    in >> n >> m;
    for (int i = 1; i <= m; ++i)
    {
        in >> x >> y;
        b[x][y] = b[y][x] = 1;
    }
    for (int i = 2; i <= n; ++i)
    {
        for (int j = 1; j < i; ++j)
        {
            if (b[i][j] == 1)
            {
                aux = (b[i] & b[j]);
                rez += aux.count();
            }
        }
    }
    out << rez / 3;
    return 0;
}