Mai intai trebuie sa te autentifici.

Cod sursa(job #1314051)

Utilizator vladrochianVlad Rochian vladrochian Data 11 ianuarie 2015 14:46:08
Problema Triplete Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 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 (size_t j = 0; j < G[i].size(); ++j)
			sol += (ad[i] & ad[G[i][j]]).count();
	fout << sol << "\n";
	return 0;
}