Cod sursa(job #2525806)

Utilizator AlexNeaguAlexandru AlexNeagu Data 17 ianuarie 2020 20:30:32
Problema Triplete Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.49 kb
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 4100;
bitset < N > E[N], x;
int ans = 0;
ifstream in("triplete.in");
ofstream out("triplete.out");
int main() {
	int n, m;
	in >> n >> m;
	while(m--) {
		int x, y;
		in >> x >> y;
		E[x][y] = 1;
		E[y][x] = 1;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			if (E[i][j]) {
				x = E[i] & E[j];
				ans += x.count();
			}
 		}
	}
	out << ans / 3 << "\n";
	return 0;
}