#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 | #63375053 | Utilizator | |
| Fișier | dijkstra.cpp | Dimensiune | 949 B |
| Data încărcării | 28 Februarie 2026, 16:18 | Scor/rezultat | Eroare de compilare |
dijkstra.cpp: In function 'void dijkstra(int)': dijkstra.cpp:11:63: 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/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, 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:11:64: error: template argument 3 is invalid priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>>pq; ^ dijkstra.cpp:11:68: error: invalid type in declaration before ';' token priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>>pq; ^ dijkstra.cpp:13:8: error: request for member 'push' in 'pq', which is of non-class type 'int' pq.push({0,start}); ^ dijkstra.cpp:14:15: error: request for member 'empty' in 'pq', which is of non-class type 'int' while(!pq.empty()) ^ dijkstra.cpp:16:13: error: expected unqualified-id before '[' token auto[d,nod]=pq.top(); ^ dijkstra.cpp:17:12: error: request for member 'pop' in 'pq', which is of non-class type 'int' pq.pop(); ^ dijkstra.cpp:18:12: error: 'd' was not declared in this scope if(d>dist[nod]) continue; ^ dijkstra.cpp:18:19: error: 'nod' was not declared in this scope if(d>dist[nod]) continue; ^ dijkstra.cpp:20:17: error: expected unqualified-id before '[' token for(auto[vec,cost]: adj[nod]) ^ dijkstra.cpp:20:17: error: expected ';' before '[' token dijkstra.cpp:20:18: error: 'vec' was not declared in this scope for(auto[vec,cost]: adj[nod]) ^ dijkstra.cpp:20:22: error: 'cost' was not declared in this scope for(auto[vec,cost]: adj[nod]) ^ dijkstra.cpp: In lambda function: dijkstra.cpp:20:27: error: expected '{' before ':' token for(auto[vec,cost]: adj[nod]) ^ dijkstra.cpp: In function 'void dijkstra(int)': dijkstra.cpp:20:27: error: expected ';' before ':' token dijkstra.cpp:20:27: error: expected primary-expression before ':' token dijkstra.cpp:20:27: error: expected ')' before ':' token dijkstra.cpp:20:27: error: expected primary-expression before ':' token dijkstra.cpp:20:27: error: expected ';' before ':' token dijkstra.cpp:46:1: error: expected '}' at end of input } ^ dijkstra.cpp:46: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ă.