#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 | #64709401 | Utilizator | |
| Fișier | dijkstra.cpp | Dimensiune | 1.17 KB |
| Data încărcării | 25 Mai 2026, 13:07 | Scor/rezultat | Eroare de compilare |
dijkstra.cpp: In function ‘int main()’: dijkstra.cpp:15:26: error: reference to ‘max’ is ambiguous 15 | a[i][j]=max; | ^~~ In file included from /usr/include/c++/13/string:51, from /usr/include/c++/13/bits/locale_classes.h:40, from /usr/include/c++/13/bits/ios_base.h:41, from /usr/include/c++/13/ios:44, from /usr/include/c++/13/istream:40, from /usr/include/c++/13/fstream:40, from dijkstra.cpp:1: /usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidates are: ‘template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: ‘template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ dijkstra.cpp:7:41: note: ‘int max’ 7 | int d[101], s[101], t[101], minim, poz, max=10000000; | ^~~ dijkstra.cpp:10:5: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 10 | for(int i=1; i<=n; i++) | ^~~ dijkstra.cpp:16:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 16 | while(f>>i>>j>>c) | ^~~~~ dijkstra.cpp:16:15: error: ‘f’ was not declared in this scope 16 | while(f>>i>>j>>c) | ^ dijkstra.cpp:22:27: error: reference to ‘max’ is ambiguous 22 | if(d[i]<max) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidates are: ‘template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: ‘template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ dijkstra.cpp:7:41: note: ‘int max’ 7 | int d[101], s[101], t[101], minim, poz, max=10000000; | ^~~ dijkstra.cpp:26:15: error: reference to ‘max’ is ambiguous 26 | minim=max; | ^~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidates are: ‘template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: ‘template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ dijkstra.cpp:7:41: note: ‘int max’ 7 | int d[101], s[101], t[101], minim, poz, max=10000000; | ^~~ dijkstra.cpp:45:13: error: ‘g’ was not declared in this scope 45 | g<<d[i]<<" "; | ^ dijkstra.cpp:47:9: error: ‘g’ was not declared in this scope 47 | g<<-1<<" "; | ^ dijkstra.cpp:43:5: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 43 | for(int i=1; i<=n; i++) | ^~~ dijkstra.cpp:48:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 48 | return 0; | ^~~~~~
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ă.