Detalii evaluare #63363452

Rezumat problemă

#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.

Detalii

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 Mancas Casian (Casian_Mancas)
Fișier dfs.cpp Dimensiune 539 B
Data încărcării 27 Februarie 2026, 21:43 Scor/rezultat Eroare de compilare

Evaluare

Mesaj 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>'

Cum funcționează evaluarea?

www.pbinfo.ro permite evaluarea a două tipuri de probleme:

  • probleme la care rezolvarea presupune scrierea unui program complet
  • probleme la care rezolvarea presupune scrierea unei secvențe de program - câteva instrucțiuni, o listă de declarații, una sau mai multe funcții, etc.

Problema DFS face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:

  • Programul sursă este compilat folosind compilatorul corespunzător. Dacă în urma compilării se obțin erori sau avertismente, acestea sunt afișate în această pagină.
  • Dacă programul a fost compilat, executabilul obținut va fi rulat, furnizându-i-se unul sau mai multe seturi de date de intrare, în concordanță cu restricțiile specifice problemei. Pentru fiecare set de date se obține un anumit punctaj, în raport cu corectitudinea soluției tale.

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ă.

Du-te sus!