#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 | #63372336 | Utilizator | |
| Fișier | dijkstra.cpp | Dimensiune | 887 B |
| Data încărcării | 28 Februarie 2026, 14:18 | Scor/rezultat | Eroare de compilare |
dijkstra.cpp: In function 'int main()': dijkstra.cpp:19:65: 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:19:66: error: template argument 3 is invalid priority_queue<pair<int,int>, vector<pair<int,int>>, greater<>> pq; ^ dijkstra.cpp:19:71: error: invalid type in declaration before ';' token priority_queue<pair<int,int>, vector<pair<int,int>>, greater<>> pq; ^ dijkstra.cpp:20:8: error: request for member 'push' in 'pq', which is of non-class type 'int' pq.push({0,p}); ^ dijkstra.cpp:21:15: 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 [dist,nod]=pq.top(); ^ dijkstra.cpp:23:12: error: request for member 'pop' in 'pq', which is of non-class type 'int' pq.pop(); ^ dijkstra.cpp:24:12: error: 'dist' was not declared in this scope if(dist>d[nod]) continue; ^ dijkstra.cpp:24:19: error: 'nod' was not declared in this scope if(dist>d[nod]) continue; ^ dijkstra.cpp:25:18: error: expected unqualified-id before '[' token for(auto [v,c]: adj[nod]){ ^ dijkstra.cpp:25:18: error: expected ';' before '[' token dijkstra.cpp:25:19: error: 'v' was not declared in this scope for(auto [v,c]: adj[nod]){ ^ dijkstra.cpp:25:21: error: 'c' was not declared in this scope for(auto [v,c]: adj[nod]){ ^ dijkstra.cpp: In lambda function: dijkstra.cpp:25:23: error: expected '{' before ':' token for(auto [v,c]: adj[nod]){ ^ dijkstra.cpp: In function 'int main()': dijkstra.cpp:25:23: error: expected ';' before ':' token dijkstra.cpp:25:23: error: expected primary-expression before ':' token dijkstra.cpp:25:23: error: expected ')' before ':' token dijkstra.cpp:25:23: error: expected primary-expression before ':' token dijkstra.cpp:25:23: error: expected ';' before ':' token dijkstra.cpp:37:1: error: expected '}' at end of input } ^ dijkstra.cpp:37: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ă.