Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Dulce enredo p1
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll random (int i) { return (rand()%i); } ll intervalo(int a, int b)//////////////ints { return rand()%(b-a+1) + a; //un numero en [a,b] } int main () { int maxtam = 20; int N, K, N_aristas = 0; srand ( unsigned ( time(0) ) ); vector<int> myvector; stack<int> total; vector<vector<int>> graficas; vector<stack<int>> stackficas; map<int, int> anterior; map<int, int> aristas; map<int, int> tamanos; N = intervalo(1,maxtam); K = intervalo(1,N); cout << N << "\n"; //cout << K << "\n"; graficas.resize(K); stackficas.resize(K); for(int i = 0; i < N; i++) { graficas[random(K)].push_back(i); } for(auto a: graficas) random_shuffle ( a.begin(), a.end() ); //random_shuffle ( myvector.begin(), myvector.end() ); for(int i = 0; i < K; i++) tamanos[i] = graficas[i].size(); /*for(auto a: tamanos) cout << a.first << " " << a.second << "\n";*/ for(int i = 0; i < K; i++) { int n = tamanos[i]; if(n > 0) aristas[i] = n-1; } for(int i = 0; i < K; i++) { for(int j = 0; j < graficas[i].size(); j++) stackficas[i].push(graficas[i][j]); } /*for(auto a: stackficas) { cout << "Grafica: \n"; while(!a.empty()) { cout << a.top() << "\n"; a.pop(); } }*/ for(auto a: aristas) { N_aristas+=a.second; } cout << N_aristas << "\n"; for(int i = 0; i < K; i++) { int n = aristas[i]; int anterior; //cout << "Aristas: \n"; while(!stackficas[i].empty() and stackficas[i].size() > 1) { cout << stackficas[i].top() << " "; stackficas[i].pop(); cout << stackficas[i].top() << "\n"; } } cout << '\n'; return 0; }
run
|
edit
|
history
|
help
0
Вариант универсального указателя.
RecursiveFact
Valuing Fixed Income Investments
Subarray with 0 sum
1
creating triangle using nested loop
Depth of Bin tree
Exempel 1
Cuantos
Op&&^Overload