#1861
TopSort
Se dă un graf orientat aciclic cu N
noduri numerotate de la 1
la N
. Să se realizeze o sortare topologică a nodurilor.
Problema | TopSort | Operații I/O |
topsort.in /topsort.out
|
---|---|---|---|
Limita timp | 0.5 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #26394056 | Utilizator | |
Fișier | topsort.cpp | Dimensiune | 724 B |
Data încărcării | 03 Decembrie 2020, 18:34 | Scor / rezultat | Eroare de compilare |
topsort.cpp: In function 'void dfs(int)': topsort.cpp:19:11: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'int') viz[u]=1; ^ topsort.cpp:19:11: note: candidates are: In file included from /usr/include/c++/4.8/vector:69:0, from /usr/include/c++/4.8/bits/random.h:34, from /usr/include/c++/4.8/random:50, from /usr/include/c++/4.8/bits/stl_algo.h:65, from /usr/include/c++/4.8/algorithm:62, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from topsort.cpp:1: /usr/include/c++/4.8/bits/vector.tcc:160:5: note: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>] vector<_Tp, _Alloc>:: ^ /usr/include/c++/4.8/bits/vector.tcc:160:5: note: no known conversion for argument 1 from 'int' to 'const std::vector<int>&' In file included from /usr/include/c++/4.8/vector:64:0, from /usr/include/c++/4.8/bits/random.h:34, from /usr/include/c++/4.8/random:50, from /usr/include/c++/4.8/bits/stl_algo.h:65, from /usr/include/c++/4.8/algorithm:62, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from topsort.cpp:1: /usr/include/c++/4.8/bits/stl_vector.h:439:7: note: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>] operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) ^ /usr/include/c++/4.8/bits/stl_vector.h:439:7: note: no known conversion for argument 1 from 'int' to 'std::vector<int>&&' /usr/include/c++/4.8/bits/stl_vector.h:461:7: note: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>] operator=(initializer_list<value_type> __l) ^ /usr/include/c++/4.8/bits/stl_vector.h:461:7: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<int>' topsort.cpp:20:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(j=0;j<G[u].size();j++) ^ topsort.cpp:23:12: error: no match for 'operator!' (operand type is 'std::vector<int>') if(!viz[v]) ^ topsort.cpp:23:12: note: candidate is: topsort.cpp:23:12: note: operator!(bool) <built-in> topsort.cpp:23:12: note: no known conversion for argument 1 from 'std::vector<int>' to 'bool' topsort.cpp: In function 'int main()': topsort.cpp:38:12: error: no match for 'operator!' (operand type is 'std::vector<int>') if(!viz[i]) dfs(i); ^ topsort.cpp:38:12: note: candidate is: topsort.cpp:38:12: note: operator!(bool) <built-in> topsort.cpp:38:12: note: no known conversion for argument 1 from 'std::vector<int>' to 'bool'
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema TopSort 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ă.