#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 | #55921451 | Utilizator | |
Fișier | dijkstra.cpp | Dimensiune | 1.27 KB |
Data încărcării | 30 Ianuarie 2025, 13:14 | Scor / rezultat | Eroare de compilare |
dijkstra.cpp:11:25: error: conflicting declaration 'int g [105][105]' int d[nmax],g[nmax][nmax],t[nmax],x,y,c,n,mini,k,p,m; ^ dijkstra.cpp:7:10: error: 'g' has a previous declaration as 'std::ofstream g' ofstream g("dijkstra.out"); ^ dijkstra.cpp: In function 'void dijkstra(int)': dijkstra.cpp:42:46: error: no match for 'operator[]' (operand types are 'std::ofstream {aka std::basic_ofstream<char>}' and 'int') if ( sel[j]==false && d[j]>d[k]+g[k][j] ) ^ dijkstra.cpp:44:28: error: no match for 'operator[]' (operand types are 'std::ofstream {aka std::basic_ofstream<char>}' and 'int') d[j]=d[k]+g[k][j]; ^ dijkstra.cpp: In function 'int main()': dijkstra.cpp:57:14: error: no match for 'operator[]' (operand types are 'std::ofstream {aka std::basic_ofstream<char>}' and 'int') g[i][j]=inf; ^ dijkstra.cpp:60:10: error: no match for 'operator[]' (operand types are 'std::ofstream {aka std::basic_ofstream<char>}' and 'int') g[x][y]=c; ^ dijkstra.cpp:63:15: error: no match for 'operator[]' (operand types are 'std::ofstream {aka std::basic_ofstream<char>}' and 'int') d[i]=g[p][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ă.