Cod sursa(job #3231491)

Utilizator DobraVictorDobra Victor Ioan DobraVictor Data 26 mai 2024 20:17:56
Problema Triplete Scor 70
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <iostream>
#include <fstream>
#include <stdint.h>
#include <bitset>

const int32_t MAX_N = 4096;

std::bitset<MAX_N> adj[MAX_N];

int main() {
	std::ifstream fin("triplete.in");
	std::ofstream fout("triplete.out");

	int32_t n, m;
	fin >> n >> m;
	for(int32_t i = 0; i != m; ++i) {
		int32_t x, y;
		fin >> x >> y;
		--x; --y;
		adj[x][y] = 1;
		adj[y][x] = 1;
	}

	int32_t count = 0;
	for(int32_t i = 0; i != n; ++i) {
		for(int32_t j = i + 1; j != n; ++j) {
			if(!adj[i][j])
				continue;
			for(int32_t k = j + 1; k != n; ++k) {
				if(adj[k][i] && adj[k][j])
					++count;
			}
		}
	}

	fout << count;

	fin.close();
	fout.close();

	return 0;
}