#19
BFS
Se consideră un graf neorientat cu n
vârfuri și m
muchii și un vârf cunoscut X
. Să se afişeze vârfurile vizitate în urma parcurgerii în lățime a grafului pornind din vârful X
.
Problema | BFS | Operații I/O |
BFS.in /BFS.out
|
---|---|---|---|
Limita timp | 1 secunde | Limita memorie |
Total: 128 MB
/
Stivă 8 MB
|
Id soluție | #20761065 | Utilizator | |
Fișier | bfs.cpp | Dimensiune | 807 B |
Data încărcării | 10 Februarie 2020, 09:27 | Scor / rezultat | Eroare de compilare |
bfs.cpp:5:12: error: variable 'std::ifstream in' has initializer but incomplete type ifstream in("BFS.in") ^ bfs.cpp:6:1: error: expected ',' or ';' before 'ofstream' ofstream out("BFS.out") ^ bfs.cpp: In function 'void BFS(int)': bfs.cpp:10:5: error: 'p' was not declared in this scope p=k=1; ^ bfs.cpp:10:7: error: 'k' was not declared in this scope p=k=1; ^ bfs.cpp:11:5: error: 'c' was not declared in this scope c[p]=X; // avem uns singur nod in coada ^ bfs.cpp:11:10: error: 'X' was not declared in this scope c[p]=X; // avem uns singur nod in coada ^ bfs.cpp:13:9: error: 'nod' was not declared in this scope nod=c[p]; // luam nodyul de la incepuitul cozii ^ bfs.cpp:14:9: error: 'viz' was not declared in this scope viz[nod]=1; // matcam n odul ca vizitat ^ bfs.cpp:15:9: error: 'out' was not declared in this scope out<<nod<<" "; ^ bfs.cpp:17:13: error: 'i' was not declared in this scope for(i=1;i<=n;i++){ ^ bfs.cpp:17:20: error: 'n' was not declared in this scope for(i=1;i<=n;i++){ ^ bfs.cpp:18:16: error: 'a' was not declared in this scope if(a[nod][i]==1 and viz[i]==0){ ^ bfs.cpp:26:5: error: expected ';' before '}' token } ^ bfs.cpp: In function 'int main()': bfs.cpp:31:9: error: 'n' was not declared in this scope in>>n>>m>>x; ^ bfs.cpp:31:12: error: 'm' was not declared in this scope in>>n>>m>>x; ^ bfs.cpp:31:15: error: 'x' was not declared in this scope in>>n>>m>>x; ^ bfs.cpp:32:9: error: 'i' was not declared in this scope for(i=1:i<=n;i++){ ^ bfs.cpp:32:12: error: expected ';' before ':' token for(i=1:i<=n;i++){ ^ bfs.cpp:32:21: error: expected ';' before ')' token for(i=1:i<=n;i++){ ^ bfs.cpp:33:13: error: 'X' was not declared in this scope in>>X>>y; ^ bfs.cpp:33:16: error: 'y' was not declared in this scope in>>X>>y; ^ bfs.cpp:34:13: error: 'a' was not declared in this scope a[x][y]=a[y][x]=1; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema BFS 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ă.