#588
Se dă un graf orientat ponderat – în care fiecare arc are asociat un cost, număr natural strict pozitiv, și un nod p
. Să se determine, folosind algoritmul lui Dijkstra, costul minim al drumului de la p
la fiecare nod al grafului.
Problema | Dijkstra | Operații I/O |
![]() dijkstra.in /dijkstra.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #58389827 | Utilizator | |
Fișier | dijkstra.cpp | Dimensiune | 1.27 KB |
Data încărcării | 31 Mai 2025, 14:50 | Scor / rezultat | Eroare de compilare |
dijkstra.cpp:9:17: error: 'INT_MAX' was not declared in this scope const int INF = INT_MAX; ^ dijkstra.cpp: In function 'std::vector<int> dijkstra(int, const Graph&)': dijkstra.cpp:17:67: error: wrong number of template arguments (0, should be 1) priority_queue<pair<int, int>, vector<pair<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/ostream:38, from /usr/include/c++/4.8/iostream:39, from dijkstra.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> ^ dijkstra.cpp:17:68: error: template argument 3 is invalid priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> pq; ^ dijkstra.cpp:17:73: error: invalid type in declaration before ';' token priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> pq; ^ dijkstra.cpp:18:8: error: request for member 'push' in 'pq', which is of non-class type 'int' pq.push({0, start}); ^ dijkstra.cpp:20:16: error: request for member 'empty' in 'pq', which is of non-class type 'int' while (!pq.empty()) ^ dijkstra.cpp:22:14: error: expected unqualified-id before '[' token auto [d, u] = pq.top(); ^ dijkstra.cpp:23:12: error: request for member 'pop' in 'pq', which is of non-class type 'int' pq.pop(); ^ dijkstra.cpp:25:13: error: 'd' was not declared in this scope if (d > dist[u]) ^ dijkstra.cpp:25:22: error: 'u' was not declared in this scope if (d > dist[u]) ^ dijkstra.cpp:28:19: error: expected unqualified-id before '[' token for (auto [v, cost] : graph[u]) ^ dijkstra.cpp:28:19: error: expected ';' before '[' token dijkstra.cpp:28:20: error: 'v' was not declared in this scope for (auto [v, cost] : graph[u]) ^ dijkstra.cpp:28:23: error: 'cost' was not declared in this scope for (auto [v, cost] : graph[u]) ^ dijkstra.cpp: In lambda function: dijkstra.cpp:28:29: error: expected '{' before ':' token for (auto [v, cost] : graph[u]) ^ dijkstra.cpp: In function 'std::vector<int> dijkstra(int, const Graph&)': dijkstra.cpp:28:29: error: expected ';' before ':' token dijkstra.cpp:28:29: error: expected primary-expression before ':' token dijkstra.cpp:28:29: error: expected ')' before ':' token dijkstra.cpp:28:29: error: expected primary-expression before ':' token dijkstra.cpp:28:29: error: expected ';' before ':' token dijkstra.cpp:63:1: error: expected '}' at end of input } ^ dijkstra.cpp:63:1: error: expected '}' at end of input dijkstra.cpp:63:1: warning: no return statement in function returning non-void [-Wreturn-type]
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Dijkstra 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ă.