#19
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 | #64395869 | Utilizator | |
| Fișier | bfs.cpp | Dimensiune | 546 B |
| Data încărcării | 05 Mai 2026, 09:27 | Scor/rezultat | Eroare de compilare |
bfs.cpp:3:9: error: expected unqualified-id before ‘,’ token 3 | ifstream, in("BFS.in") | ^ bfs.cpp:3:13: error: variable ‘std::ifstream in’ has initializer but incomplete type 3 | ifstream, in("BFS.in") | ^ bfs.cpp:4:1: error: expected ‘,’ or ‘;’ before ‘ofstream’ 4 | ofstream out("BFS.out") | ^~~~~~~~ bfs.cpp: In function ‘int main()’: bfs.cpp:7:9: error: ‘n’ was not declared in this scope; did you mean ‘in’? 7 | in>>n>>m>>x; | ^ | in bfs.cpp:7:12: error: ‘m’ was not declared in this scope; did you mean ‘tm’? 7 | in>>n>>m>>x; | ^ | tm bfs.cpp:7:15: error: ‘x’ was not declared in this scope 7 | in>>n>>m>>x; | ^ bfs.cpp:9:13: error: ‘v1’ was not declared in this scope 9 | in>>v1>>v2; | ^~ bfs.cpp:9:17: error: ‘v2’ was not declared in this scope 9 | in>>v1>>v2; | ^~ bfs.cpp:10:9: error: ‘a’ was not declared in this scope 10 | a[v1][v2]=a[v2][v1]=1; | ^ bfs.cpp:12:5: error: ‘p’ was not declared in this scope 12 | p=1;u=1;c[p]=x;v[x]=1; | ^ bfs.cpp:12:9: error: ‘u’ was not declared in this scope 12 | p=1;u=1;c[p]=x;v[x]=1; | ^ bfs.cpp:12:13: error: ‘c’ was not declared in this scope 12 | p=1;u=1;c[p]=x;v[x]=1; | ^ bfs.cpp:12:20: error: ‘v’ was not declared in this scope 12 | p=1;u=1;c[p]=x;v[x]=1; | ^ bfs.cpp:15:16: error: ‘a’ was not declared in this scope 15 | if(a[c[p]][i]==1&&v[i]==0){ | ^ bfs.cpp:22:9: error: ‘out’ was not declared in this scope 22 | out<<c[i]<<" "; | ^~~
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ă.