#588
Dijkstra
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 | #54155240 | Utilizator | |
Fișier | dijkstra.cpp | Dimensiune | 1.23 KB |
Data încărcării | 20 Noiembrie 2024, 21:58 | Scor / rezultat | Eroare de compilare |
dijkstra.cpp: In function 'void dijkstra(int)': dijkstra.cpp:16:67: error: wrong number of template arguments (0, should be 1) priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> pq; // (cost, nod) ^ 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:16:68: error: template argument 3 is invalid priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> pq; // (cost, nod) ^ dijkstra.cpp:16:73: error: invalid type in declaration before ';' token priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> pq; // (cost, nod) ^ 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:21:14: error: expected unqualified-id before '[' token auto [d, node] = pq.top(); pq.pop(); // Costul și nodul curent ^ dijkstra.cpp:21:39: error: request for member 'pop' in 'pq', which is of non-class type 'int' auto [d, node] = pq.top(); pq.pop(); // Costul și nodul curent ^ dijkstra.cpp:22:13: error: 'd' was not declared in this scope if (d > dist[node]) continue; ^ dijkstra.cpp:22:22: error: 'node' was not declared in this scope if (d > dist[node]) continue; ^ dijkstra.cpp:24:19: error: expected unqualified-id before '[' token for (auto [neigh, cost] : adj[node]) { // Parcurgem vecinii ^ dijkstra.cpp:24:19: error: expected ';' before '[' token dijkstra.cpp:24:20: error: 'neigh' was not declared in this scope for (auto [neigh, cost] : adj[node]) { // Parcurgem vecinii ^ dijkstra.cpp:24:27: error: 'cost' was not declared in this scope for (auto [neigh, cost] : adj[node]) { // Parcurgem vecinii ^ dijkstra.cpp: In lambda function: dijkstra.cpp:24:33: error: expected '{' before ':' token for (auto [neigh, cost] : adj[node]) { // Parcurgem vecinii ^ dijkstra.cpp: In function 'void dijkstra(int)': dijkstra.cpp:24:33: error: expected ';' before ':' token dijkstra.cpp:24:33: error: expected primary-expression before ':' token dijkstra.cpp:24:33: error: expected ')' before ':' token dijkstra.cpp:24:33: error: expected primary-expression before ':' token dijkstra.cpp:24:33: error: expected ';' before ':' token dijkstra.cpp:48:1: error: expected '}' at end of input } ^ dijkstra.cpp:48:1: error: expected '}' at end of input
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ă.