#4156
Într-un arbore cu rădăcină, nivelul unui nod este lungime lanțului de la rădăcină la acel nod. Astfel, rădăcina este pe nivelul 0
, fiii rădăcinii pe nivelul 1
, fiii fiilor rădăcinii pe nivelul 2
, etc.
Se dă vectorul de tați al unui arbore cu rădăcină cu n
noduri. Determinați nodurile situate pe nivele pare.
Problema | NivelePare | Operații I/O |
![]() nivelepare.in /nivelepare.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #57973382 | Utilizator | |
Fișier | nivelepare.cpp | Dimensiune | 2.13 KB |
Data încărcării | 06 Mai 2025, 10:33 | Scor / rezultat | Eroare de compilare |
nivelepare.cpp: In function 'void afisare_iesire(int, const std::vector<int>&)': nivelepare.cpp:41:50: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (nivele[i] >= nivele_pe_pare.size()) { ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from nivelepare.cpp:5: /usr/include/c++/4.8/bits/stl_algo.h: In instantiation of 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]': /usr/include/c++/4.8/bits/stl_algo.h:2211:62: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]' /usr/include/c++/4.8/bits/stl_algo.h:5462:47: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]' nivelepare.cpp:52:44: required from here /usr/include/c++/4.8/bits/stl_algo.h:2142:17: error: assignment of read-only location '__first.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator*<const int*, std::vector<int> >()' *__first = _GLIBCXX_MOVE(__val); ^ In file included from /usr/include/c++/4.8/queue:62:0, from nivelepare.cpp:3: /usr/include/c++/4.8/bits/stl_heap.h: In instantiation of 'void std::__pop_heap(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]': /usr/include/c++/4.8/bits/stl_algo.h:1936:42: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]' /usr/include/c++/4.8/bits/stl_algo.h:5308:51: required from 'void std::partial_sort(_RAIter, _RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]' /usr/include/c++/4.8/bits/stl_algo.h:2310:60: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Size = int]' /usr/include/c++/4.8/bits/stl_algo.h:5461:36: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]' nivelepare.cpp:52:44: required from here /usr/include/c++/4.8/bits/stl_heap.h:262:17: error: assignment of read-only location '__result.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator*<const int*, std::vector<int> >()' *__result = _GLIBCXX_MOVE(*__first); ^ /usr/include/c++/4.8/bits/stl_heap.h: In instantiation of 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Distance = int; _Tp = int]': /usr/include/c++/4.8/bits/stl_heap.h:407:71: required from 'void std::make_heap(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]' /usr/include/c++/4.8/bits/stl_algo.h:1933:39: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]' /usr/include/c++/4.8/bits/stl_algo.h:5308:51: required from 'void std::partial_sort(_RAIter, _RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]' /usr/include/c++/4.8/bits/stl_algo.h:2310:60: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Size = int]' /usr/include/c++/4.8/bits/stl_algo.h:5461:36: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]' nivelepare.cpp:52:44: required from here /usr/include/c++/4.8/bits/stl_heap.h:237:29: error: assignment of read-only location '__first.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator+<const int*, std::vector<int> >((*(const difference_type*)(& __holeIndex))).__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator*<const int*, std::vector<int> >()' *(__first + __holeIndex) = _GLIBCXX_MOVE(*(__first + __secondChild)); ^ /usr/include/c++/4.8/bits/stl_heap.h:243:29: error: assignment of read-only location '__first.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator+<const int*, std::vector<int> >((*(const difference_type*)(& __holeIndex))).__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator*<const int*, std::vector<int> >()' *(__first + __holeIndex) = _GLIBCXX_MOVE(*(__first ^ In file included from /usr/include/c++/4.8/bits/stl_pair.h:59:0, from /usr/include/c++/4.8/bits/stl_algobase.h:64, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from nivelepare.cpp:1: /usr/include/c++/4.8/bits/move.h: In instantiation of 'void std::swap(_Tp&, _Tp&) [with _Tp = const int]': /usr/include/c++/4.8/bits/stl_algobase.h:147:22: required from 'void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _ForwardIterator2 = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]' /usr/include/c++/4.8/bits/stl_algo.h:88:34: required from 'void std::__move_median_to_first(_Iterator, _Iterator, _Iterator, _Iterator) [with _Iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]' /usr/include/c++/4.8/bits/stl_algo.h:2282:74: required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]' /usr/include/c++/4.8/bits/stl_algo.h:2315:54: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Size = int]' /usr/include/c++/4.8/bits/stl_algo.h:5461:36: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]' nivelepare.cpp:52:44: required from here /usr/include/c++/4.8/bits/move.h:176:11: error: assignment of read-only reference '__a' __a = _GLIBCXX_MOVE(__b); ^ /usr/include/c++/4.8/bits/move.h:177:11: error: assignment of read-only reference '__b' __b = _GLIBCXX_MOVE(__tmp); ^ 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/ostream:38, from /usr/include/c++/4.8/iostream:39, from nivelepare.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h: In instantiation of '_BI2 std::__copy_move_backward_a(_BI1, _BI1, _BI2) [with bool _IsMove = true; _BI1 = const int*; _BI2 = const int*]': /usr/include/c++/4.8/bits/stl_algobase.h:596:33: required from '_BI2 std::__copy_move_backward_a2(_BI1, _BI1, _BI2) [with bool _IsMove = true; _BI1 = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _BI2 = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]' /usr/include/c++/4.8/bits/stl_algobase.h:667:15: required from '_BI2 std::move_backward(_BI1, _BI1, _BI2) [with _BI1 = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _BI2 = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]' /usr/include/c++/4.8/bits/stl_algo.h:2141:8: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]' /usr/include/c++/4.8/bits/stl_algo.h:2211:62: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]' /usr/include/c++/4.8/bits/stl_algo.h:5462:47: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]' nivelepare.cpp:52:44: required from here /usr/include/c++/4.8/bits/stl_algobase.h:587:18: error: no matching function for call to 'std::__copy_move_backward<true, true, std::random_access_iterator_tag>::__copy_move_b(const int*&, const int*&, const int*&)' __result); ^ /usr/include/c++/4.8/bits/stl_algobase.h:587:18: note: candidate is: /usr/include/c++/4.8/bits/stl_algobase.h:563:9: note: template<class _Tp> static _Tp* std::__copy_move_backward<_IsMove, true, std::random_access_iterator_tag>::__copy_move_b(const _Tp*, const _Tp*, _Tp*) [with _Tp = _Tp; bool _IsMove = true] __copy_move_b(const _Tp* __first, const _Tp* __last, _Tp* __result) ^ /usr/include/c++/4.8/bits/stl_algobase.h:563:9: note: template argument deduction/substitution failed: /usr/include/c++/4.8/bits/stl_algobase.h:587:18: note: deduced conflicting types for parameter '_Tp' ('int' and 'const int') __result); ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema NivelePare 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ă.