Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
CIDP2k19
#include <bits/stdc++.h> #define MAXTAM 100 using namespace std; vector<int> lista[MAXTAM]; bool visit[MAXTAM] = {0}; map<int, int> cuentas; void dfs(int nodo, int inicial) { cuentas[inicial]++; visit[nodo] = true; for(auto c: lista[nodo]) { if(!visit[c]) { dfs(c, inicial); } } } int main() { int a, b, total, parcial = 0, residuo; int T, K; int count = 0; cin >> T; cin >> K; while(K--) { cin >> a; cin >> b; lista[a].push_back(b); lista[b].push_back(a); } for(int i = 0; i < T; i++) { if(!visit[i]) { dfs(i, i); count++; } } total = T*(T-1); cout << "Total: " << total << "\n"; for(auto a: cuentas) { parcial += (a.second)*(a.second - 1); } cout << "Parcial: " << parcial << "\n"; residuo = total - parcial; // cout << "Primero: " << residuo/2 << " Segundo: " << residuo/4 << " Tercero: " << residuo/4 << "\n"; }
run
|
edit
|
history
|
help
0
Test constructors and operators
subset sum=k(Recursion)
TraiectorieIdeala
e-olymp.com---problem1590---Birthday 2
project euler problem - 3
c++
Roots of a Quadratic Equation
pi with cmath
VecScalMultiOpLaod
Simulare 2022