#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 | #42557719 | Utilizator | |
Fișier | kruskal.cpp | Dimensiune | 1.09 KB |
Data încărcării | 10 Martie 2023, 09:08 | Scor / rezultat | Eroare de compilare |
kruskal.cpp: In function 'int leaga(int, int)': kruskal.cpp:25:1: warning: no return statement in function returning non-void [-Wreturn-type] } ^ kruskal.cpp: In function 'int main()': kruskal.cpp:43:5: error: expected ';' before 'for' for(int i=1;i<=n;i++){ ^ kruskal.cpp:43:17: error: 'i' was not declared in this scope for(int i=1;i<=n;i++){ ^ kruskal.cpp:43:25: error: expected ';' before ')' token for(int i=1;i<=n;i++){ ^ kruskal.cpp:48:22: error: 'muchiii' was not declared in this scope int r1 = rad(muchiii].i); ^ kruskal.cpp:49:32: error: '__gnu_cxx::__alloc_traits<std::allocator<_m> >::value_type' has no member named 'j' int r2 = rad(muchii[i].j); ^ kruskal.cpp:52:13: error: 'rez' was not declared in this scope rez += muchii[i].c; ^ kruskal.cpp:57:12: error: 'rez' was not declared in this scope out << rez << endl; ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from kruskal.cpp:3: /usr/include/c++/4.8/bits/stl_algo.h: In instantiation of '_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<_m*, std::vector<_m> >; _Tp = _m; _Compare = main()::__lambda0]': /usr/include/c++/4.8/bits/stl_algo.h:2296:78: required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<_m*, std::vector<_m> >; _Compare = main()::__lambda0]' /usr/include/c++/4.8/bits/stl_algo.h:2337:62: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<_m*, std::vector<_m> >; _Size = int; _Compare = main()::__lambda0]' /usr/include/c++/4.8/bits/stl_algo.h:5499:44: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<_m*, std::vector<_m> >; _Compare = main()::__lambda0]' kruskal.cpp:42:11: required from here /usr/include/c++/4.8/bits/stl_algo.h:2263:35: error: no match for call to '(main()::__lambda0) (_m&, const _m&)' while (__comp(*__first, __pivot)) ^ kruskal.cpp:40:39: note: candidates are: sort(muchii.begin(),muchii.end(),[](_m &a,_m &b){ ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from kruskal.cpp:3: /usr/include/c++/4.8/bits/stl_algo.h:2263:35: note: bool (*)(_m&, _m&) <conversion> while (__comp(*__first, __pivot)) ^ /usr/include/c++/4.8/bits/stl_algo.h:2263:35: note: candidate expects 3 arguments, 3 provided kruskal.cpp:40:52: note: main()::__lambda0 sort(muchii.begin(),muchii.end(),[](_m &a,_m &b){ ^ kruskal.cpp:40:52: note: no known conversion for argument 2 from 'const _m' to '_m&' In file included from /usr/include/c++/4.8/algorithm:62:0, from kruskal.cpp:3: /usr/include/c++/4.8/bits/stl_algo.h:2266:34: error: no match for call to '(main()::__lambda0) (const _m&, _m&)' while (__comp(__pivot, *__last)) ^ kruskal.cpp:40:39: note: candidates are: sort(muchii.begin(),muchii.end(),[](_m &a,_m &b){ ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from kruskal.cpp:3: /usr/include/c++/4.8/bits/stl_algo.h:2266:34: note: bool (*)(_m&, _m&) <conversion> while (__comp(__pivot, *__last)) ^ /usr/include/c++/4.8/bits/stl_algo.h:2266:34: note: candidate expects 3 arguments, 3 provided kruskal.cpp:40:52: note: main()::__lambda0 sort(muchii.begin(),muchii.end(),[](_m &a,_m &b){ ^ kruskal.cpp:40:52: note: no known conversion for argument 1 from 'const _m' to '_m&'
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ă.