Cod sursa(job #1314045)

Utilizator vladrochianVlad Rochian vladrochian Data 11 ianuarie 2015 14:39:37
Problema Triplete Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <fstream>
#include <bitset>
#include <vector>
using namespace std;

const int kMaxN = 4100;

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

int N, M, sol;
bitset<kMaxN> ad[kMaxN];
vector<int> G[kMaxN];

int main() {
	fin >> N >> M;
	while (M--) {
		int x, y;
		fin >> x >> y;
		if (x > y)
			swap(x, y);
		G[x].push_back(y);
		ad[x][y] = true;
	}
	for (int i = 1; i < N - 1; ++i)
		for (int j : G[i])
			sol += (ad[i] & ad[j]).count();
	fout << sol << "\n";
	return 0;
}