#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 | #60489294 | Utilizator | |
| Fișier | dijkstra.cpp | Dimensiune | 946 B |
| Data încărcării | 03 Noiembrie 2025, 13:09 | Scor/rezultat | Eroare de compilare |
dijkstra.cpp:4:13: error: variable 'std::ifstream fin' has initializer but incomplete type ifstream fin("dijkstra.in") ^ dijkstra.cpp:5:1: error: expected ',' or ';' before 'ofstream' ofstream fout("dijkstra.out") ^ dijkstra.cpp: In function 'void cit_init()': dijkstra.cpp:10:6: error: 'n' was not declared in this scope fin>>n>>x; ^ dijkstra.cpp:10:9: error: 'x' was not declared in this scope fin>>n>>x; ^ dijkstra.cpp:13:14: error: 'a' was not declared in this scope if(i!=j) a[i][j]=INF; ^ dijkstra.cpp:15:5: error: 'a' was not declared in this scope a[i][j]=c; ^ dijkstra.cpp:17:8: error: 'a' was not declared in this scope if(a[x][i]!=INF&&x!=i) ^ dijkstra.cpp:19:5: error: 'd' was not declared in this scope d[i]=a[x][i]; ^ dijkstra.cpp:20:5: error: 'p' was not declared in this scope p[i]=x; ^ dijkstra.cpp:22:23: error: 'd' was not declared in this scope else if(a[x][i]=INF) d[i]=INF; ^ dijkstra.cpp: In function 'void Dijkstra()': dijkstra.cpp:26:6: error: 's' was not declared in this scope s[x]=1;int dmin; ^ dijkstra.cpp:26:8: error: 'x' was not declared in this scope s[x]=1;int dmin; ^ dijkstra.cpp:27:10: error: 'i' was not declared in this scope for(i=1;i<=n;i++) ^ dijkstra.cpp:27:17: error: 'n' was not declared in this scope for(i=1;i<=n;i++) ^ dijkstra.cpp:30:14: error: 'j' was not declared in this scope for(j=1;j<=n;j++) ^ dijkstra.cpp:31:25: error: 'd' was not declared in this scope if(s[j]==0&&d[j]<dmin) ^ dijkstra.cpp:33:24: error: 'k' was not declared in this scope dmin=d[j];k=j; ^ dijkstra.cpp:35:12: error: 'k' was not declared in this scope s[k]=1; ^ dijkstra.cpp:36:14: error: 'j' was not declared in this scope for(j=1;j<=n;j++) ^ dijkstra.cpp:38:16: error: 'd' was not declared in this scope if(d[j]>d[k]+a[k][j]) ^ dijkstra.cpp:38:26: error: 'a' was not declared in this scope if(d[j]>d[k]+a[k][j]) ^ dijkstra.cpp:41:14: error: 'p' was not declared in this scope p[j]=k; ^ dijkstra.cpp: In function 'int main()': dijkstra.cpp:49:13: error: 'afisare' was not declared in this scope afisare(); ^
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ă.