Detalii evaluare #64347506

Rezumat problemă

Gigel are un set de n cuburi. Fiecare cub este marcat cu un număr natural, de la 1 la n și i se cunoaște lungimea laturii – număr natural. Cu o parte dintre aceste cuburi Gigel va construi o stivă, astfel:

  • fiecare cub se analizează o singură dată, în ordinea numerelor marcate;
  • dacă stiva nu conține niciun cub, cubul curent devine baza stivei
  • dacă cubul curent are latura mai mică sau egală cu cubul din vârful stive, se adaugă pe stivă;
  • dacă cubul curent are latura mai mare decât cubul din vârful stivei, se vor înlătura de pe stivă cuburi (eventual toate) până când cubul curent are latura mai mică sau egală cu cubul din vârful stivei.

Să se afișeze numerele de pe cuburile existente la final în stivă, de la bază spre vârf.

Detalii

Problema Cuburi2 Operații I/O tastatură/ecran
Limita timp 0.1 secunde Limita memorie Total: 64 MB / Stivă 8 MB
Id soluție #64347506 Utilizator Strugari Natalia (StrugariNatalia)
Fișier cuburi2.cpp Dimensiune 618 B
Data încărcării 30 Aprilie 2026, 21:28 Scor/rezultat Eroare de compilare

Evaluare

Mesaj compilare

cuburi2.cpp:7:4: error: expected unqualified-id before ‘{’ token
    7 |    {
      |    ^
cuburi2.cpp: In function ‘int main()’:
cuburi2.cpp:22:15: error: aggregate ‘cub c’ has incomplete type and cannot be defined
   22 |           cub c;
      |               ^
cuburi2.cpp:29:32: error: no match for ‘operator>’ (operand types are ‘int’ and ‘__gnu_cxx::__alloc_traits<std::allocator<cub>, cub>::value_type’ {aka ‘cub’})
   29 |           while(!s.empty() && x>s.top()lat)
      |                               ~^~~~~~~~
      |                               |      |
      |                               int    __gnu_cxx::__alloc_traits<std::allocator<cub>, cub>::value_type {aka cub}
In file included from /usr/include/c++/13/string:48,
                 from /usr/include/c++/13/bits/locale_classes.h:40,
                 from /usr/include/c++/13/bits/ios_base.h:41,
                 from /usr/include/c++/13/ios:44,
                 from /usr/include/c++/13/ostream:40,
                 from /usr/include/c++/13/iostream:41,
                 from cuburi2.cpp:1:
/usr/include/c++/13/bits/stl_iterator.h:469:5: note: candidate: ‘template<class _Iterator> bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)’
  469 |     operator>(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:469:5: note:   template argument deduction/substitution failed:
cuburi2.cpp:29:39: note:   mismatched types ‘const std::reverse_iterator<_Iterator>’ and ‘int’
   29 |           while(!s.empty() && x>s.top()lat)
      |                                       ^
/usr/include/c++/13/bits/stl_iterator.h:514:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)’
  514 |     operator>(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:514:5: note:   template argument deduction/substitution failed:
cuburi2.cpp:29:39: note:   mismatched types ‘const std::reverse_iterator<_Iterator>’ and ‘int’
   29 |           while(!s.empty() && x>s.top()lat)
      |                                       ^
/usr/include/c++/13/bits/stl_iterator.h:1725:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)’
 1725 |     operator>(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:1725:5: note:   template argument deduction/substitution failed:
cuburi2.cpp:29:39: note:   mismatched types ‘const std::move_iterator<_IteratorL>’ and ‘int’
   29 |           while(!s.empty() && x>s.top()lat)
      |                                       ^
/usr/include/c++/13/bits/stl_iterator.h:1784:5: note: candidate: ‘template<class _Iterator> bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)’
 1784 |     operator>(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:1784:5: note:   template argument deduction/substitution failed:
cuburi2.cpp:29:39: note:   mismatched types ‘const std::move_iterator<_IteratorL>’ and ‘int’
   29 |           while(!s.empty() && x>s.top()lat)
      |                                       ^
In file included from /usr/include/c++/13/bits/stl_algobase.h:64,
                 from /usr/include/c++/13/string:51:
/usr/include/c++/13/bits/stl_pair.h:848:5: note: candidate: ‘template<class _T1, class _T2> constexpr bool std::operator>(const pair<_T1, _T2>&, const pair<_T1, _T2>&)’
  848 |     operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:848:5: note:   template argument deduction/substitution failed:
cuburi2.cpp:29:39: note:   mismatched types ‘const std::pair<_T1, _T2>’ and ‘int’
   29 |           while(!s.empty() && x>s.top()lat)
      |                                       ^
In file included from /usr/include/c++/13/string:54:
/usr/include/c++/13/bits/basic_string.h:3870:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Alloc>&, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)’
 3870 |     operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/13/bits/basic_string.h:3870:5: note:   template argument deduction/substitution failed:
cuburi2.cpp:29:39: note:   mismatched types ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’ and ‘int’
   29 |           while(!s.empty() && x>s.top()lat)
      |                                       ^
/usr/include/c++/13/bits/basic_string.h:3884:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)’
 3884 |     operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/13/bits/basic_string.h:3884:5: note:   template argument deduction/substitution failed:
cuburi2.cpp:29:39: note:   mismatched types ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’ and ‘int’
   29 |           while(!s.empty() && x>s.top()lat)
      |                                       ^
/usr/include/c++/13/bits/basic_string.h:3897:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)’
 3897 |     operator>(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/13/bits/basic_string.h:3897:5: note:   template argument deduction/substitution failed:
cuburi2.cpp:29:39: note:   mismatched types ‘const _CharT*’ and ‘int’
   29 |           while(!s.empty() && x>s.top()lat)
      |                                       ^
In file included from /usr/include/c++/13/deque:66,
                 from /usr/include/c++/13/stack:62,
                 from cuburi2.cpp:2:
/usr/include/c++/13/bits/stl_deque.h:2345:5: note: candidate: ‘template<class _Tp, class _Alloc> bool std::operator>(const deque<_Tp, _Alloc>&, const deque<_Tp, _Alloc>&)’
 2345 |     operator>(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_deque.h:2345:5: note:   template argument deduction/substitution failed:
cuburi2.cpp:29:39: note:   mismatched types ‘const std::deque<_Tp, _Alloc>’ and ‘int’
   29 |           while(!s.empty() && x>s.top()lat)
      |                                       ^
In file included from /usr/include/c++/13/stack:63:
/usr/include/c++/13/bits/stl_stack.h:389:5: note: candidate: ‘template<class _Tp, class _Seq> bool std::operator>(const stack<_Tp, _Seq>&, const stack<_Tp, _Seq>&)’
  389 |     operator>(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_stack.h:389:5: note:   template argument deduction/substitution failed:
cuburi2.cpp:29:39: note:   mismatched types ‘const std::stack<_Tp, _Seq>’ and ‘int’
   29 |           while(!s.empty() && x>s.top()lat)
      |                                       ^
cuburi2.cpp:29:40: error: expected ‘)’ before ‘lat’
   29 |           while(!s.empty() && x>s.top()lat)
      |                ~                       ^~~
      |                                        )
cuburi2.cpp:29:40: error: ‘lat’ was not declared in this scope
   29 |           while(!s.empty() && x>s.top()lat)
      |                                        ^~~
cuburi2.cpp:31:15: error: aggregate ‘cub c’ has incomplete type and cannot be defined
   31 |           cub c;
      |               ^
/usr/include/c++/13/bits/stl_deque.h: In instantiation of ‘void std::_Deque_base<_Tp, _Alloc>::_M_initialize_map(std::size_t) [with _Tp = cub; _Alloc = std::allocator<cub>; std::size_t = long unsigned int]’:
/usr/include/c++/13/bits/stl_deque.h:460:9:   required from ‘std::_Deque_base<_Tp, _Alloc>::_Deque_base() [with _Tp = cub; _Alloc = std::allocator<cub>]’
/usr/include/c++/13/bits/stl_deque.h:855:7:   required from ‘std::stack<_Tp, _Sequence>::stack() [with _Seq = std::deque<cub, std::allocator<cub> >; _Requires = void; _Tp = cub; _Sequence = std::deque<cub, std::allocator<cub> >]’
cuburi2.cpp:11:14:   required from here
/usr/include/c++/13/bits/stl_deque.h:641:69: error: invalid application of ‘sizeof’ to incomplete type ‘cub’
  641 |       const size_t __num_nodes = (__num_elements / __deque_buf_size(sizeof(_Tp))
      |                                                                     ^~~~~~~~~~~
/usr/include/c++/13/bits/stl_deque.h:672:60: error: invalid application of ‘sizeof’ to incomplete type ‘cub’
  672 |                                         % __deque_buf_size(sizeof(_Tp)));
      |                                                            ^~~~~~~~~~~
/usr/include/c++/13/bits/stl_deque.h: In instantiation of ‘void std::deque<_Tp, _Alloc>::_M_destroy_data(iterator, iterator, const std::allocator<_CharT>&) [with _Tp = cub; _Alloc = std::allocator<cub>; iterator = std::_Deque_base<cub, std::allocator<cub> >::iterator]’:
/usr/include/c++/13/bits/stl_deque.h:1028:24:   required from ‘std::deque<_Tp, _Alloc>::~deque() [with _Tp = cub; _Alloc = std::allocator<cub>]’
/usr/include/c++/13/bits/stl_stack.h:163:4:   required from ‘std::stack<_Tp, _Sequence>::stack() [with _Seq = std::deque<cub, std::allocator<cub> >; _Requires = void; _Tp = cub; _Sequence = std::deque<cub, std::allocator<cub> >]’
cuburi2.cpp:11:14:   required from here
/usr/include/c++/13/bits/stl_deque.h:2090:14: error: invalid use of incomplete type ‘std::deque<cub, std::allocator<cub> >::value_type’ {aka ‘struct cub’} [-fpermissive]
 2090 |         if (!__has_trivial_destructor(value_type))
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cuburi2.cpp:6:11: note: forward declaration of ‘std::deque<cub, std::allocator<cub> >::value_type’ {aka ‘struct cub’}
    6 |    struct cub;
      |           ^~~
/usr/include/c++/13/bits/stl_deque.h: In instantiation of ‘std::_Deque_iterator<_Tp, _Ref, _Ptr>::_Self& std::_Deque_iterator<_Tp, _Ref, _Ptr>::operator--() [with _Tp = cub; _Ref = cub&; _Ptr = cub*; _Self = std::_Deque_iterator<cub, cub&, cub*>::_Self]’:
/usr/include/c++/13/bits/stl_deque.h:1472:2:   required from ‘std::deque<_Tp, _Alloc>::reference std::deque<_Tp, _Alloc>::back() [with _Tp = cub; _Alloc = std::allocator<cub>; reference = cub&]’
/usr/include/c++/13/bits/stl_stack.h:235:15:   required from ‘std::stack<_Tp, _Sequence>::reference std::stack<_Tp, _Sequence>::top() [with _Tp = cub; _Sequence = std::deque<cub, std::allocator<cub> >; reference = cub&]’
cuburi2.cpp:29:38:   required from here
/usr/include/c++/13/bits/stl_deque.h:217:11: error: cannot decrement a pointer to incomplete type ‘cub’
  217 |         --_M_cur;
      |           ^~~~~~
/usr/include/c++/13/bits/stl_deque.h: In instantiation of ‘std::_Deque_iterator<cub, cub&, cub*>::difference_type std::operator-(const _Deque_iterator<cub, cub&, cub*>::_Self&, const _Deque_iterator<cub, cub&, cub*>::_Self&)’:
/usr/include/c++/13/bits/stl_deque.h:1269:40:   required from ‘std::deque<_Tp, _Alloc>::size_type std::deque<_Tp, _Alloc>::size() const [with _Tp = cub; _Alloc = std::allocator<cub>; size_type = long unsigned int]’
/usr/include/c++/13/bits/stl_stack.h:224:22:   required from ‘std::stack<_Tp, _Sequence>::size_type std::stack<_Tp, _Sequence>::size() const [with _Tp = cub; _Sequence = std::deque<cub, std::allocator<cub> >; size_type = long unsigned int]’
cuburi2.cpp:37:15:   required from here
/usr/include/c++/13/bits/stl_deque.h:374:25: error: invalid use of incomplete type ‘struct cub’
  374 |           + (__x._M_cur - __x._M_first)
      |             ~~~~~~~~~~~~^~~~~~~~~~~~~~~
cuburi2.cpp:6:11: note: forward declaration of ‘struct cub’
    6 |    struct cub;
      |           ^~~
/usr/include/c++/13/bits/stl_deque.h:375:26: error: invalid use of incomplete type ‘struct cub’
  375 |           + (__y._M_last - __y._M_cur);
      |             ~~~~~~~~~~~~~^~~~~~~~~~~~~
cuburi2.cpp:6:11: note: forward declaration of ‘struct cub’
    6 |    struct cub;
      |           ^~~
/usr/include/c++/13/bits/stl_deque.h: In instantiation of ‘void std::_Deque_base<_Tp, _Alloc>::_M_deallocate_node(_Ptr) [with _Tp = cub; _Alloc = std::allocator<cub>; _Ptr = cub*]’:
/usr/include/c++/13/bits/stl_deque.h:700:2:   required from ‘void std::_Deque_base<_Tp, _Alloc>::_M_destroy_nodes(_Map_pointer, _Map_pointer) [with _Tp = cub; _Alloc = std::allocator<cub>; _Map_pointer = cub**]’
/usr/include/c++/13/bits/stl_deque.h:622:4:   required from ‘std::_Deque_base<_Tp, _Alloc>::~_Deque_base() [with _Tp = cub; _Alloc = std::allocator<cub>]’
/usr/include/c++/13/bits/stl_deque.h:855:7:   required from ‘std::stack<_Tp, _Sequence>::stack() [with _Seq = std::deque<cub, std::allocator<cub> >; _Requires = void; _Tp = cub; _Sequence = std::deque<cub, std::allocator<cub> >]’
cuburi2.cpp:11:14:   required from here
/usr/include/c++/13/bits/stl_deque.h:590:60: error: invalid application of ‘sizeof’ to incomplete type ‘cub’
  590 |         _Traits::deallocate(_M_impl, __p, __deque_buf_size(sizeof(_Tp)));
      |                                                            ^~~~~~~~~~~
/usr/include/c++/13/bits/stl_deque.h: In instantiation of ‘static std::size_t std::_Deque_iterator<_Tp, _Ref, _Ptr>::_S_buffer_size() [with _Tp = cub; _Ref = cub&; _Ptr = cub*; std::size_t = long unsigned int]’:
/usr/include/c++/13/bits/stl_deque.h:372:39:   required from ‘std::_Deque_iterator<cub, cub&, cub*>::difference_type std::operator-(const _Deque_iterator<cub, cub&, cub*>::_Self&, const _Deque_iterator<cub, cub&, cub*>::_Self&)’
/usr/include/c++/13/bits/stl_deque.h:1269:40:   required from ‘std::deque<_Tp, _Alloc>::size_type std::deque<_Tp, _Alloc>::size() const [with _Tp = cub; _Alloc = std::allocator<cub>; size_type = long unsigned int]’
/usr/include/c++/13/bits/stl_stack.h:224:22:   required from ‘std::stack<_Tp, _Sequence>::size_type std::stack<_Tp, _Sequence>::size() const [with _Tp = cub; _Sequence = std::deque<cub, std::allocator<cub> >; size_type = long unsigned int]’
cuburi2.cpp:37:15:   required from here
/usr/include/c++/13/bits/stl_deque.h:132:33: error: invalid application of ‘sizeof’ to incomplete type ‘cub’
  132 |       { return __deque_buf_size(sizeof(_Tp)); }
      |                                 ^~~~~~~~~~~

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 Cuburi2 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!