#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 | #42342048 | Utilizator | |
Fișier | kruskal.cpp | Dimensiune | 1.22 KB |
Data încărcării | 01 Martie 2023, 19:36 | Scor / rezultat | Eroare de compilare |
kruskal.cpp: In function 'int main()': kruskal.cpp:27:9: error: 'c' was not declared in this scope c[i] = i; ^ kruskal.cpp:31:11: error: no match for 'operator=' (operand types are 'muchie' and 'const value_type {aka const int}') z = q.top(); ^ kruskal.cpp:31:11: note: candidates are: kruskal.cpp:6:8: note: muchie& muchie::operator=(const muchie&) struct muchie { ^ kruskal.cpp:6:8: note: no known conversion for argument 1 from 'const value_type {aka const int}' to 'const muchie&' kruskal.cpp:6:8: note: muchie& muchie::operator=(muchie&&) kruskal.cpp:6:8: note: no known conversion for argument 1 from 'const value_type {aka const int}' to 'muchie&&' kruskal.cpp:33:13: error: 'c' was not declared in this scope if (c[v[z.x]] != c[v[z.y]]) ^ kruskal.cpp:37:18: error: 'j' was not declared in this scope for (j = 1; j <= n; ++ j) ^ kruskal.cpp:40:15: error: no match for 'operator[]' (operand types are 'int [101]' and 'muchie') ok[z] = true; ^ kruskal.cpp:42:22: error: no match for 'operator[]' (operand types are 'std::vector<muchie>' and 'muchie') cost += v[z].c; ^ kruskal.cpp:42:22: note: candidates are: In file included from /usr/include/c++/4.8/vector:64:0, from /usr/include/c++/4.8/queue:61, from kruskal.cpp:2: /usr/include/c++/4.8/bits/stl_vector.h:770:7: note: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = muchie; _Alloc = std::allocator<muchie>; std::vector<_Tp, _Alloc>::reference = muchie&; std::vector<_Tp, _Alloc>::size_type = unsigned int] operator[](size_type __n) ^ /usr/include/c++/4.8/bits/stl_vector.h:770:7: note: no known conversion for argument 1 from 'muchie' to 'std::vector<muchie>::size_type {aka unsigned int}' /usr/include/c++/4.8/bits/stl_vector.h:785:7: note: std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = muchie; _Alloc = std::allocator<muchie>; std::vector<_Tp, _Alloc>::const_reference = const muchie&; std::vector<_Tp, _Alloc>::size_type = unsigned int] operator[](size_type __n) const ^ /usr/include/c++/4.8/bits/stl_vector.h:785:7: note: no known conversion for argument 1 from 'muchie' to 'std::vector<muchie>::size_type {aka unsigned int}'
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ă.