#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 | #63363452 | Utilizator | |
| Fișier | dfs.cpp | Dimensiune | 539 B |
| Data încărcării | 27 Februarie 2026, 21:43 | Scor/rezultat | Eroare de compilare |
dfs.cpp: In function 'void dfs(int)': dfs.cpp:10:11: error: no match for 'operator=' (operand types are 'std::vector<bool>' and 'bool') viz[x]=true; ^ dfs.cpp:10: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:13:12: error: no match for 'operator!' (operand type is 'std::vector<bool>') if(!viz[v]) dfs(v); ^ dfs.cpp:13:12: note: candidate is: dfs.cpp:13:12: note: operator!(bool) <built-in> dfs.cpp:13:12: note: no known conversion for argument 1 from 'std::vector<bool>' to 'bool' In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from dfs.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h: In instantiation of 'typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = std::vector<bool>*; _Tp = bool; typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type = void]': /usr/include/c++/4.8/bits/stl_algobase.h:729:14: required from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = std::vector<bool>*; _Tp = bool]' dfs.cpp:18:29: required from here /usr/include/c++/4.8/bits/stl_algobase.h:693:11: error: no match for 'operator=' (operand types are 'std::vector<bool>' and 'const bool') *__first = __tmp; ^ /usr/include/c++/4.8/bits/stl_algobase.h:693: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 'const 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 'const 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 'const bool' to 'std::initializer_list<bool>'
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ă.