#539
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 adâncime a grafului pornind din vârful X.
| Problema | DFS | Operații I/O |
dfs.in/dfs.out
|
|---|---|---|---|
| Limita timp | 1 secunde | Limita memorie |
Total: 128 MB
/
Stivă 8 MB
|
| Id soluție | #64659411 | Utilizator | |
| Fișier | dfs.cpp | Dimensiune | 406 B |
| Data încărcării | 21 Mai 2026, 08:32 | Scor/rezultat | Eroare de compilare |
dfs.cpp:3:20: error: expected ‘;’ before ‘ifstream’ 3 | using namespace std | ^ | ; 4 | 5 | ifstream fin("dfs.in"); | ~~~~~~~~ dfs.cpp: In function ‘void dfs(int)’: dfs.cpp:10:5: error: ‘v’ was not declared in this scope 10 | v[x]=1; | ^ dfs.cpp:11:21: error: ‘n’ was not declared in this scope 11 | for( int i=1;i<=n;i++) | ^ dfs.cpp:12:12: error: ‘a’ was not declared in this scope 12 | if(a[x][i]==1 && v[i]==0) | ^ dfs.cpp: In function ‘int main()’: dfs.cpp:18:10: error: ‘n’ was not declared in this scope 18 | fin>>n>>m>>x; | ^ dfs.cpp:18:13: error: ‘m’ was not declared in this scope; did you mean ‘tm’? 18 | fin>>n>>m>>x; | ^ | tm dfs.cpp:18:16: error: ‘x’ was not declared in this scope 18 | fin>>n>>m>>x; | ^ dfs.cpp:19:9: error: ‘i’ was not declared in this scope 19 | for(i=1;i<=m;i++) | ^ dfs.cpp:21:14: error: ‘v1’ was not declared in this scope 21 | fin>>v1>>v2; | ^~ dfs.cpp:21:18: error: ‘v2’ was not declared in this scope 21 | fin>>v1>>v2; | ^~ dfs.cpp:22:9: error: ‘a’ was not declared in this scope 22 | a[v1][v2]==a[v2][v1]=1; | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema DFS 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ă.