#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 | #63363447 | Utilizator | |
| Fișier | dfs.cpp | Dimensiune | 527 B |
| Data încărcării | 27 Februarie 2026, 21:43 | Scor/rezultat | Eroare de compilare |
dfs.cpp: In function 'void dfs(int)': dfs.cpp:9:11: error: no match for 'operator=' (operand types are 'std::vector<bool>' and 'bool') viz[x]=true; ^ dfs.cpp:9:11: note: candidates are: In file included from /usr/include/c++/4.8/vector:65:0, from dfs.cpp:2: /usr/include/c++/4.8/bits/stl_bvector.h:624:5: note: std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(const std::vector<bool, _Alloc>&) [with _Alloc = std::allocator<bool>] operator=(const vector& __x) ^ /usr/include/c++/4.8/bits/stl_bvector.h:624:5: note: no known conversion for argument 1 from 'bool' to 'const std::vector<bool>&' /usr/include/c++/4.8/bits/stl_bvector.h:640:5: note: std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(std::vector<bool, _Alloc>&&) [with _Alloc = std::allocator<bool>] operator=(vector&& __x) ^ /usr/include/c++/4.8/bits/stl_bvector.h:640:5: note: no known conversion for argument 1 from 'bool' to 'std::vector<bool>&&' /usr/include/c++/4.8/bits/stl_bvector.h:650:5: note: std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(std::initializer_list<bool>) [with _Alloc = std::allocator<bool>] operator=(initializer_list<bool> __l) ^ /usr/include/c++/4.8/bits/stl_bvector.h:650:5: note: no known conversion for argument 1 from 'bool' to 'std::initializer_list<bool>' dfs.cpp:12:12: error: no match for 'operator!' (operand type is 'std::vector<bool>') if(!viz[v]) dfs(v); ^ dfs.cpp:12:12: note: candidate is: dfs.cpp:12:12: note: operator!(bool) <built-in> dfs.cpp:12:12: note: no known conversion for argument 1 from 'std::vector<bool>' to 'bool' dfs.cpp: In function 'int main()': dfs.cpp:16:10: error: 'n' was not declared in this scope fin>>n>>m>>x; ^ dfs.cpp:16:13: error: 'm' was not declared in this scope fin>>n>>m>>x; ^ dfs.cpp:16:16: error: 'x' was not declared in this scope fin>>n>>m>>x; ^
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ă.