#588
Dijkstra
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 | #29655849 | Utilizator | |
Fișier | dijkstra.cpp | Dimensiune | 2.16 KB |
Data încărcării | 13 Mai 2021, 23:48 | Scor / rezultat | Eroare de compilare |
dijkstra.cpp:7:1: error: 'ifstream' does not name a type ifstream fin("dijkstra.in"); ^ dijkstra.cpp:8:1: error: 'ofstream' does not name a type ofstream fout("dijkstra.out"); ^ dijkstra.cpp:11:10: error: 'maxn' was not declared in this scope int dist[maxn]; //costurile de la start la toate nodurile ^ dijkstra.cpp:12:7: error: 'maxn' was not declared in this scope int s[maxn]; // marchez nodurile selectate (nodurile pentru care am gasit deja drumul minim) ^ dijkstra.cpp:13:7: error: 'maxn' was not declared in this scope int t[maxn]; // predecesorii fiecarui nod i in drumul de la nodul de start ^ dijkstra.cpp:14:9: error: 'maxn' was not declared in this scope int mat[maxn][maxn]; ^ dijkstra.cpp:14:15: error: 'maxn' was not declared in this scope int mat[maxn][maxn]; ^ dijkstra.cpp: In function 'void citire()': dijkstra.cpp:17:3: error: 'fin' was not declared in this scope fin>>n>>m; ^ dijkstra.cpp:20:7: error: 'mat' was not declared in this scope mat[i][j] = inf; ^ dijkstra.cpp:24:5: error: 'mat' was not declared in this scope mat[x][y] = cost; ^ dijkstra.cpp: In function 'void dijkstra(int)': dijkstra.cpp:30:5: error: 'dist' was not declared in this scope dist[i]=inf; ^ dijkstra.cpp:31:3: error: 'dist' was not declared in this scope dist[start]=0; // dist de la start la el insusi e 0 ^ dijkstra.cpp:38:28: error: 's' was not declared in this scope if (dist[j]<mini && !s[j]){ ^ dijkstra.cpp:45:5: error: 's' was not declared in this scope s[pmin] = 1; //marcam ca si selectat nodul intermediar ^ dijkstra.cpp:47:30: error: 'mat' was not declared in this scope if (dist[i]>dist[pmin]+mat[pmin][i]){ //daca costul deja memorat al nodului nr_nod e mai mare decat costul ^ dijkstra.cpp:49:9: error: 't' was not declared in this scope t[i] = pmin; ^ dijkstra.cpp: In function 'int main()': dijkstra.cpp:61:9: error: 'fout' was not declared in this scope fout<<dist[i]; ^ dijkstra.cpp:61:15: error: 'dist' was not declared in this scope fout<<dist[i]; ^ dijkstra.cpp:62:10: error: 'fout' was not declared in this scope else fout<<0; ^ dijkstra.cpp:63:3: error: 'fout' was not declared in this scope fout<<endl; ^ dijkstra.cpp:63:9: error: 'endl' was not declared in this scope fout<<endl; ^ dijkstra.cpp:63:9: note: suggested alternative: In file included from /usr/include/c++/4.8/iostream:39:0, from dijkstra.cpp:1: /usr/include/c++/4.8/ostream:564:5: note: 'std::endl' endl(basic_ostream<_CharT, _Traits>& __os) ^
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ă.