#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 | #63735537 | Utilizator | |
| Fișier | dijkstra.cpp | Dimensiune | 1.25 KB |
| Data încărcării | 17 Martie 2026, 10:17 | Scor/rezultat | Eroare de compilare |
dijkstra.cpp:5:1: error: expected ',' or ';' before 'int' int a[101][101],n,d[101][101],t[101],viz[101]; ^ dijkstra.cpp: In function 'void init()': dijkstra.cpp:9:20: error: 'n' was not declared in this scope for(int i=1;i<=n;i++) ^ dijkstra.cpp:11:5: error: 'a' was not declared in this scope a[i][j]=inf; ^ dijkstra.cpp: In function 'void citire()': dijkstra.cpp:15:10: error: 'n' was not declared in this scope fin>>n; ^ dijkstra.cpp:19:9: error: 'a' was not declared in this scope a[x][y]=c; ^ dijkstra.cpp:21:17: error: a function-definition is not allowed here before '{' token void drum(int i){ ^ dijkstra.cpp: In function 'int main()': dijkstra.cpp:32:5: error: 'd' was not declared in this scope d[start]=0; ^ dijkstra.cpp:33:5: error: 'viz' was not declared in this scope viz[start]=1; ^ dijkstra.cpp:34:5: error: 't' was not declared in this scope t[start]=0; ^ dijkstra.cpp:35:20: error: 'n' was not declared in this scope for(int i=1;i<=n;i++){ ^ dijkstra.cpp:36:14: error: 'a' was not declared in this scope d[i]=a[start][i]; ^ dijkstra.cpp:37:15: error: 'j' was not declared in this scope if(i!=j && a[start][i]!=inf) ^ dijkstra.cpp:41:13: warning: unused variable 'x' [-Wunused-variable] int x; ^ dijkstra.cpp:43:20: error: 'n' was not declared in this scope for(int i=1;i<=n;i++) ^ dijkstra.cpp:50:13: error: 'x' was not declared in this scope x=i; ^ dijkstra.cpp:53:8: error: 'mini' was not declared in this scope if(mini!=inf) ^ dijkstra.cpp:55:24: error: 'n' was not declared in this scope for(int i=1;i<=n;i++) ^ dijkstra.cpp:57:18: error: 'j' was not declared in this scope if(d[j]=d[x]+a[x][j]) ^ dijkstra.cpp:57:23: error: 'x' was not declared in this scope if(d[j]=d[x]+a[x][j]) ^ dijkstra.cpp:57:26: error: 'a' was not declared in this scope if(d[j]=d[x]+a[x][j]) ^ dijkstra.cpp:64:20: error: 'n' was not declared in this scope for(int i=1;i<=n;i++) ^ dijkstra.cpp:67:14: error: 'i' was not declared in this scope drum(i); ^ dijkstra.cpp:67:15: error: 'drum' was not declared in this scope drum(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ă.