Cod sursa(job #1314048)

Utilizator vladrochianVlad Rochian vladrochian Data 11 ianuarie 2015 14:42:47
Problema Triplete Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.58 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], aux;
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]) {
			aux = ad[i] & ad[j];
			for (int k = j + 1; k <= N; ++k)
				if (aux[k])
					++sol;
		}
	fout << sol << "\n";
	return 0;
}