#592
Kruskal
Se dă un graf neorientat ponderat conex cu n
vârfuri și m
muchii – în care fiecare muchie are asociat un cost, număr natural strict pozitiv. Folosind algoritmul lui Kruskal, determinați un arbore parțial de cost minim.
Problema | Kruskal | Operații I/O |
kruskal.in /kruskal.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #42341952 | Utilizator | |
Fișier | kruskal.cpp | Dimensiune | 1.11 KB |
Data încărcării | 01 Martie 2023, 19:32 | Scor / rezultat | Eroare de compilare |
kruskal.cpp:6:1: error: 'vector' does not name a type vector <muchie> v; ^ kruskal.cpp: In member function 'bool compara::operator()(int, int)': kruskal.cpp:10:29: error: 'v' was not declared in this scope return v[a].c > v[b].c; ^ kruskal.cpp: At global scope: kruskal.cpp:13:1: error: 'priority_queue' does not name a type priority_queue <int, vector<int>, compara > q; ^ kruskal.cpp: In function 'int main()': kruskal.cpp:16:5: error: 'f' was not declared in this scope f >> n >> m; ^ kruskal.cpp:16:10: error: 'n' was not declared in this scope f >> n >> m; ^ kruskal.cpp:16:15: error: 'm' was not declared in this scope f >> n >> m; ^ kruskal.cpp:17:10: error: 'i' was not declared in this scope for (i = 1; i <= m; ++ i) ^ kruskal.cpp:19:14: error: 'v' was not declared in this scope f >> v[i].x >> v[i].y >> v[i].c; ^ kruskal.cpp:20:9: error: 'q' was not declared in this scope q.push(i); ^ kruskal.cpp:22:10: error: 'i' was not declared in this scope for (i = 1; i <= n; ++ i) ^ kruskal.cpp:23:9: error: 'c' was not declared in this scope c[i] = i; ^ kruskal.cpp:24:5: error: 'nr' was not declared in this scope nr = 0; ^ kruskal.cpp:25:10: error: 'i' was not declared in this scope for (i = 1; i <= nr; ++ i) ^ kruskal.cpp:27:13: error: 'q' was not declared in this scope z = q.top(); ^ kruskal.cpp:29:13: error: 'c' was not declared in this scope if (c[v[z.x]] != c[v[z.y]]) ^ kruskal.cpp:29:15: error: 'v' was not declared in this scope if (c[v[z.x]] != c[v[z.y]]) ^ kruskal.cpp:31:13: error: 'mi' was not declared in this scope mi = min(c[v[z.x]], c[v[z.y]]); ^ kruskal.cpp:32:13: error: 'mx' was not declared in this scope mx = max(c[v[z.x]], c[v[z.y]]); ^ kruskal.cpp:33:18: error: 'j' was not declared in this scope for (j = 1; j <= n; ++ j) ^ kruskal.cpp:36:13: error: 'ok' was not declared in this scope ok[z] = true; ^ kruskal.cpp:38:13: error: 'cost' was not declared in this scope cost += v[z].c; ^ kruskal.cpp:43:5: error: 'g' was not declared in this scope g << cost << '\n'; ^ kruskal.cpp:43:10: error: 'cost' was not declared in this scope g << cost << '\n'; ^ kruskal.cpp:44:10: error: 'i' was not declared in this scope for (i = 1; i <= nr; ++ i) ^ kruskal.cpp:45:13: error: 'ok' was not declared in this scope if (ok[i]) ^ kruskal.cpp:46:14: error: 'v' was not declared in this scope g << v[i].x << " " << v[i].y << '\n'; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Kruskal face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.