Cod sursa(job #2508337)

Utilizator Dragos1226Dragos Chileban Dragos1226 Data 11 decembrie 2019 22:00:52
Problema Triplete Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.62 kb
#include<fstream>
#include<bitset>
using namespace std;
ifstream in("triplete.in");
ofstream out("triplete.out");
const int NMax = 4096;
bitset <NMax+5> G[NMax+5], x;

int N, M, Sol;

void Read () {
    in >> N >> M;
    for (int i = 0,x,y; i <= M; i++) {
        in >> x >> y;
        G[x][y] = 1;
        G[y][x] = 1;
    }
}

void Solve() {
    for (int i = 1; i <= N; i++)
        for (int j = i+1; j <= N; j++) {
            if (G[i][j]) {
                x = G[i] & G[j];
                Sol += x.count();
            }
    }
    out << Sol / 3 << '\n';
}

int main () {
    Read();
    Solve();
}