#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 | #64171058 | Utilizator | |
| Fișier | dijkstra.cpp | Dimensiune | 1.19 KB |
| Data încărcării | 21 Aprilie 2026, 13:58 | Scor/rezultat | Eroare de compilare |
dijkstra.cpp: In function ‘void citire()’: dijkstra.cpp:8:5: error: ‘inr’ was not declared in this scope; did you mean ‘int’? 8 | inr i,j,x,y,z; | ^~~ | int dijkstra.cpp:9:8: error: ‘n’ was not declared in this scope 9 | f>>n>>x0; | ^ dijkstra.cpp:9:11: error: ‘x0’ was not declared in this scope 9 | f>>n>>x0; | ^~ dijkstra.cpp:13:17: error: ‘c’ was not declared in this scope 13 | c[i][j]=0; | ^ dijkstra.cpp:15:17: error: ‘c’ was not declared in this scope 15 | c[x][y]=z; | ^ dijkstra.cpp:15:19: error: ‘x’ was not declared in this scope 15 | c[x][y]=z; | ^ dijkstra.cpp:15:22: error: ‘y’ was not declared in this scope 15 | c[x][y]=z; | ^ dijkstra.cpp:15:25: error: ‘z’ was not declared in this scope 15 | c[x][y]=z; | ^ dijkstra.cpp:16:14: error: ‘x’ was not declared in this scope 16 | while(f>>x>>y>>z) | ^ dijkstra.cpp:16:17: error: ‘y’ was not declared in this scope 16 | while(f>>x>>y>>z) | ^ dijkstra.cpp:16:20: error: ‘z’ was not declared in this scope 16 | while(f>>x>>y>>z) | ^ dijkstra.cpp:17:9: error: ‘c’ was not declared in this scope 17 | c[x][y]=z; | ^ dijkstra.cpp: In function ‘void dj(int)’: dijkstra.cpp:21:10: error: expected primary-expression before ‘int’ 21 | fo9r(int i=1;i<=n;i++) | ^~~ dijkstra.cpp:21:18: error: ‘i’ was not declared in this scope 21 | fo9r(int i=1;i<=n;i++) | ^ dijkstra.cpp:21:21: error: ‘n’ was not declared in this scope 21 | fo9r(int i=1;i<=n;i++) | ^ dijkstra.cpp:27:5: error: ‘t’ was not declared in this scope; did you mean ‘tm’? 27 | t[x0]=0; | ^ | tm dijkstra.cpp:28:5: error: ‘viz’ was not declared in this scope 28 | viz[x0]=1; | ^~~ dijkstra.cpp:29:5: error: ‘ok’ was not declared in this scope 29 | ok=1; | ^~ dijkstra.cpp:32:9: error: ‘mini’ was not declared in this scope 32 | mini=INT_MAX; | ^~~~ dijkstra.cpp:32:14: error: ‘INT_MAX’ was not declared in this scope 32 | mini=INT_MAX; | ^~~~~~~ dijkstra.cpp:3:1: note: ‘INT_MAX’ is defined in header ‘<climits>’; did you forget to ‘#include <climits>’? 2 | #include <fstream> +++ |+#include <climits> 3 | using namespace std; dijkstra.cpp:34:32: error: ‘d’ was not declared in this scope 34 | if(!viz[i] && mini>d[i]) | ^ dijkstra.cpp:37:17: error: ‘k’ was not declared in this scope 37 | k=i; | ^ dijkstra.cpp:33:9: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 33 | for(int i=1;i<=n;i++) | ^~~ dijkstra.cpp:39:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 39 | if(mini!=INT_MAX) | ^~ dijkstra.cpp:41:21: error: ‘k’ was not declared in this scope 41 | viz[k]=1; | ^ dijkstra.cpp:43:35: error: ‘d’ was not declared in this scope 43 | if(!viz[i] && d[i]>d[k]+c[k]][i]) | ^ dijkstra.cpp:43:45: error: ‘c’ was not declared in this scope 43 | if(!viz[i] && d[i]>d[k]+c[k]][i]) | ^ dijkstra.cpp:43:49: error: expected ‘)’ before ‘]’ token 43 | if(!viz[i] && d[i]>d[k]+c[k]][i]) | ~ ^ | ) dijkstra.cpp:43:49: error: expected primary-expression before ‘]’ token dijkstra.cpp: In function ‘void drum(int)’: dijkstra.cpp:56:14: error: ‘t’ was not declared in this scope 56 | drum(t[i]); | ^
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ă.