Cod sursa(job #2829071)

Utilizator andrei_C1Andrei Chertes andrei_C1 Data 8 ianuarie 2022 11:38:47
Problema Triplete Scor 90
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.47 kb
#include <bits/stdc++.h>

using namespace std;

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

const int NMAX = 4096;

int N, M, ans;

vector<pair<int, int>> v;
bitset<NMAX> mat[NMAX];

int main() {
	fin >> N >> M;

	for(int i = 0; i < M; i++) {
		int x, y;
		fin >> x >> y;

		v.push_back({x, y});
		mat[x][y] = 1;
		mat[y][x] = 1;
	}

	for(int i = 0; i < M; i++) {
		ans += (mat[v[i].first] & mat[v[i].second]).count();
	}

	fout << ans / 3 << '\n';
	return 0;
}