#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 | #58085111 | Utilizator | |
Fișier | dijkstra.cpp | Dimensiune | 1.03 KB |
Data încărcării | 13 Mai 2025, 12:50 | Scor / rezultat | Eroare de compilare |
dijkstra.cpp:5:9: error: two or more data types in declaration of 'n' int int n, p, i, j, c, a[102][102], INF=1000000000, viz[102], d[102], t[102], nod; ^ dijkstra.cpp:5:12: error: two or more data types in declaration of 'p' int int n, p, i, j, c, a[102][102], INF=1000000000, viz[102], d[102], t[102], nod; ^ dijkstra.cpp:5:15: error: two or more data types in declaration of 'i' int int n, p, i, j, c, a[102][102], INF=1000000000, viz[102], d[102], t[102], nod; ^ dijkstra.cpp:5:18: error: two or more data types in declaration of 'j' int int n, p, i, j, c, a[102][102], INF=1000000000, viz[102], d[102], t[102], nod; ^ dijkstra.cpp:5:21: error: two or more data types in declaration of 'c' int int n, p, i, j, c, a[102][102], INF=1000000000, viz[102], d[102], t[102], nod; ^ dijkstra.cpp:5:34: error: two or more data types in declaration of 'a' int int n, p, i, j, c, a[102][102], INF=1000000000, viz[102], d[102], t[102], nod; ^ dijkstra.cpp:5:37: error: two or more data types in declaration of 'INF' int int n, p, i, j, c, a[102][102], INF=1000000000, viz[102], d[102], t[102], nod; ^ dijkstra.cpp:5:60: error: two or more data types in declaration of 'viz' int int n, p, i, j, c, a[102][102], INF=1000000000, viz[102], d[102], t[102], nod; ^ dijkstra.cpp:5:68: error: two or more data types in declaration of 'd' int int n, p, i, j, c, a[102][102], INF=1000000000, viz[102], d[102], t[102], nod; ^ dijkstra.cpp:5:76: error: two or more data types in declaration of 't' int int n, p, i, j, c, a[102][102], INF=1000000000, viz[102], d[102], t[102], nod; ^ dijkstra.cpp:5:79: error: two or more data types in declaration of 'nod' int int n, p, i, j, c, a[102][102], INF=1000000000, viz[102], d[102], t[102], nod; ^ dijkstra.cpp: In function 'int mini()': dijkstra.cpp:9:20: error: 'n' was not declared in this scope for(int i=1;i<=n;i++) ^ dijkstra.cpp:11:12: error: 'viz' was not declared in this scope if(viz[i]==0 && d[i]<mini) ^ dijkstra.cpp:11:25: error: 'd' was not declared in this scope if(viz[i]==0 && d[i]<mini) ^ dijkstra.cpp: In function 'int main()': dijkstra.cpp:21:9: error: 'n' was not declared in this scope in>>n>>p; ^ dijkstra.cpp:21:12: error: 'p' was not declared in this scope in>>n>>p; ^ dijkstra.cpp:24:9: error: 'a' was not declared in this scope a[k][z]=INF; ^ dijkstra.cpp:24:17: error: 'INF' was not declared in this scope a[k][z]=INF; ^ dijkstra.cpp:25:15: error: 'i' was not declared in this scope while(in>>i>>j>>c) ^ dijkstra.cpp:25:18: error: 'j' was not declared in this scope while(in>>i>>j>>c) ^ dijkstra.cpp:25:21: error: 'c' was not declared in this scope while(in>>i>>j>>c) ^ dijkstra.cpp:27:9: error: 'a' was not declared in this scope a[i][j]=c; ^ dijkstra.cpp:29:5: error: 'viz' was not declared in this scope viz[p]=1; ^ dijkstra.cpp:32:9: error: 'd' was not declared in this scope d[k]=a[p][k]; ^ dijkstra.cpp:32:14: error: 'a' was not declared in this scope d[k]=a[p][k]; ^ dijkstra.cpp:33:16: error: 'INF' was not declared in this scope if(a[p][k]<INF) ^ dijkstra.cpp:35:9: error: 't' was not declared in this scope t[k]=p; ^ dijkstra.cpp:38:5: error: 't' was not declared in this scope t[p]=-1; ^ dijkstra.cpp:39:5: error: 'nod' was not declared in this scope nod=mini(); ^ dijkstra.cpp:44:30: error: 'a' was not declared in this scope if(viz[i]==0 && (a[nod][i]+d[nod]<d[i])) ^ dijkstra.cpp:44:40: error: 'd' was not declared in this scope if(viz[i]==0 && (a[nod][i]+d[nod]<d[i])) ^ dijkstra.cpp:53:9: error: 'i' was not declared in this scope for(i=1;i<=n;i++) ^ dijkstra.cpp:54:14: error: 'd' was not declared in this scope out<<d[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ă.