#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 | #64103959 | Utilizator | |
| Fișier | bfs.cpp | Dimensiune | 344 B |
| Data încărcării | 17 Aprilie 2026, 09:28 | Scor/rezultat | Eroare de compilare |
bfs.cpp:5:6: error: expected initializer before ‘.’ token 5 | int n.m.x.a[101][101],i,j,vi,vf,c[101],viz[101],pi,ps,k; | ^ bfs.cpp: In function ‘int main()’: bfs.cpp:7:7: error: ‘n’ was not declared in this scope 7 | {fin>>n>>m>>x; | ^ bfs.cpp:7:10: error: ‘m’ was not declared in this scope; did you mean ‘tm’? 7 | {fin>>n>>m>>x; | ^ | tm bfs.cpp:7:13: error: ‘x’ was not declared in this scope 7 | {fin>>n>>m>>x; | ^ bfs.cpp:8:6: error: ‘k’ was not declared in this scope 8 | for(k=1;k<=m;k++) | ^ bfs.cpp:9:8: error: ‘vi’ was not declared in this scope; did you mean ‘void’? 9 | {fin>>vi>>vf; | ^~ | void bfs.cpp:9:12: error: ‘vf’ was not declared in this scope 9 | {fin>>vi>>vf; | ^~ bfs.cpp:10:3: error: ‘a’ was not declared in this scope 10 | a[vi][vf]=a[vf][vi]=1; | ^ bfs.cpp:12:2: error: ‘pi’ was not declared in this scope 12 | pi=ps=1; | ^~ bfs.cpp:12:5: error: ‘ps’ was not declared in this scope 12 | pi=ps=1; | ^~ bfs.cpp:13:2: error: ‘c’ was not declared in this scope 13 | c[pi]=x; | ^ bfs.cpp:14:2: error: ‘viz’ was not declared in this scope 14 | viz[x]=1; | ^~~ bfs.cpp:16:3: error: ‘z’ was not declared in this scope 16 | {z=c[ps]; | ^ bfs.cpp:17:7: error: ‘k’ was not declared in this scope 17 | for(k=1;k<=n;k++) | ^ bfs.cpp:18:13: error: expected ‘)’ at end of input 18 | if(viz | ~ ^ | ) bfs.cpp:18:13: error: expected statement at end of input bfs.cpp:17:3: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 17 | for(k=1;k<=n;k++) | ^~~ bfs.cpp:18:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 18 | if(viz | ^ bfs.cpp:18:13: error: expected ‘}’ at end of input bfs.cpp:16:2: note: to match this ‘{’ 16 | {z=c[ps]; | ^ bfs.cpp:18:13: error: expected ‘}’ at end of input 18 | if(viz | ^ bfs.cpp:7:1: note: to match this ‘{’ 7 | {fin>>n>>m>>x; | ^
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ă.