#590
Prim
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 Prim, determinați un arbore parțial de cost minim, cu rădăcina în vârful 1
.
Problema | Prim | Operații I/O |
![]() prim.in /prim.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #58430748 | Utilizator | |
Fișier | prim.cpp | Dimensiune | 1.46 KB |
Data încărcării | 03 Iunie 2025, 21:14 | Scor / rezultat | Eroare de compilare |
prim.cpp: In function 'std::vector<std::tuple<int, int, int> > Prim(int, std::vector<std::vector<std::pair<int, int> > >&, std::vector<int>&)': prim.cpp:12:79: error: wrong number of template arguments (0, should be 1) priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<>> pq; ^ In file included from /usr/include/c++/4.8/string:48:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from prim.cpp:1: /usr/include/c++/4.8/bits/stl_function.h:222:12: error: provided for 'template<class _Tp> struct std::greater' struct greater : public binary_function<_Tp, _Tp, bool> ^ prim.cpp:12:80: error: template argument 3 is invalid priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<>> pq; ^ prim.cpp:12:85: error: invalid type in declaration before ';' token priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<>> pq; ^ prim.cpp:15:15: error: expected unqualified-id before '[' token for (auto [v, w] : adj[1]) { ^ prim.cpp:15:15: error: expected ';' before '[' token prim.cpp:15:16: error: 'v' was not declared in this scope for (auto [v, w] : adj[1]) { ^ prim.cpp:15:19: error: 'w' was not declared in this scope for (auto [v, w] : adj[1]) { ^ prim.cpp: In lambda function: prim.cpp:15:22: error: expected '{' before ':' token for (auto [v, w] : adj[1]) { ^ prim.cpp: In function 'std::vector<std::tuple<int, int, int> > Prim(int, std::vector<std::vector<std::pair<int, int> > >&, std::vector<int>&)': prim.cpp:15:22: error: expected ';' before ':' token prim.cpp:15:22: error: expected primary-expression before ':' token prim.cpp:15:22: error: expected ')' before ':' token prim.cpp:15:22: error: expected primary-expression before ':' token prim.cpp:15:22: error: expected ';' before ':' token prim.cpp:19:16: error: request for member 'empty' in 'pq', which is of non-class type 'int' while (!pq.empty() && MST.size() < V - 1) { ^ prim.cpp:19:44: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] while (!pq.empty() && MST.size() < V - 1) { ^ prim.cpp:20:14: error: expected unqualified-id before '[' token auto [w, u, v] = pq.top(); ^ prim.cpp:21:12: error: request for member 'pop' in 'pq', which is of non-class type 'int' pq.pop(); ^ prim.cpp:23:19: error: 'v' was not declared in this scope if (inMST[v]) continue; ^ prim.cpp:25:15: error: 'v' was not declared in this scope inMST[v] = true; ^ prim.cpp:26:21: error: 'u' was not declared in this scope parent[v] = u; ^ prim.cpp:27:32: error: 'w' was not declared in this scope MST.emplace_back(u, v, w); ^ prim.cpp:29:19: error: expected unqualified-id before '[' token for (auto [next, weight] : adj[v]) { ^ prim.cpp:29:19: error: expected ';' before '[' token prim.cpp:29:26: error: 'weight' was not declared in this scope for (auto [next, weight] : adj[v]) { ^ prim.cpp: In lambda function: prim.cpp:29:34: error: expected '{' before ':' token for (auto [next, weight] : adj[v]) { ^ prim.cpp: In function 'std::vector<std::tuple<int, int, int> > Prim(int, std::vector<std::vector<std::pair<int, int> > >&, std::vector<int>&)': prim.cpp:29:19: error: overloaded function with no contextual type information for (auto [next, weight] : adj[v]) { ^ prim.cpp:29:34: error: expected ';' before ':' token for (auto [next, weight] : adj[v]) { ^ prim.cpp:29:34: error: expected primary-expression before ':' token prim.cpp:29:34: error: expected ')' before ':' token prim.cpp:29:34: error: expected primary-expression before ':' token prim.cpp:29:34: error: expected ';' before ':' token prim.cpp:64:1: error: expected '}' at end of input } ^ prim.cpp:64:1: error: expected '}' at end of input prim.cpp:64:1: warning: no return statement in function returning non-void [-Wreturn-type]
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Prim 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ă.