#870
Se consideră un depou de cale ferată precum cel din imagine:

Pe linia A se află n vagoane, numerotate cu valori distincte de la 1 la n, într-o ordine oarecare. Vagoanele trebuie mutate pe linia C, în ordinea 1 2 .. n. Pentru aceasta se poate muta câte un vagon de pe o linie pe alta, în ordinea indicată de săgeți:
A -> B, A -> C sau B -> C.
Să se determine o succesiune de operații care să mute toate vagoanele de pe linia A pe linia C în ordinea dorită.
| Problema | Depou | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #63544802 | Utilizator | |
| Fișier | depou.cpp | Dimensiune | 716 B |
| Data încărcării | 09 Martie 2026, 07:50 | Scor/rezultat | Eroare de compilare |
depou.cpp:5:13: error: variable 'std::ifstream fin' has initializer but incomplete type ifstream fin("sort_div.in"); ^ depou.cpp:6:14: error: variable 'std::ofstream fout' has initializer but incomplete type ofstream fout("sort_div.out"); ^ depou.cpp:8:1: error: 'queue' does not name a type queue ^ depou.cpp: In function 'int main()': depou.cpp:12:9: error: 'n' was not declared in this scope cin>>n; ^ depou.cpp:13:8: error: 'i' was not declared in this scope for(i=1;i<=n;i++) ^ depou.cpp:15:14: error: 'x' was not declared in this scope cin>>x; ^ depou.cpp:21:18: error: invalid use of member function (did you forget the '()' ?) if(b.empty==0 && c.empty==0) ^ depou.cpp:21:32: error: invalid use of member function (did you forget the '()' ?) if(b.empty==0 && c.empty==0) ^ depou.cpp:22:22: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator+' if(b.top==c.top+1) ^ depou.cpp:24:22: error: no matching function for call to 'std::stack<int>::push(<unresolved overloaded function type>)' c.push(b.top); ^ depou.cpp:24:22: note: candidates are: In file included from /usr/include/c++/4.8/stack:61:0, from depou.cpp:2: /usr/include/c++/4.8/bits/stl_stack.h:186:7: note: void std::stack<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; std::stack<_Tp, _Sequence>::value_type = int] push(const value_type& __x) ^ /usr/include/c++/4.8/bits/stl_stack.h:186:7: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const value_type& {aka const int&}' /usr/include/c++/4.8/bits/stl_stack.h:191:7: note: void std::stack<_Tp, _Sequence>::push(std::stack<_Tp, _Sequence>::value_type&&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; std::stack<_Tp, _Sequence>::value_type = int] push(value_type&& __x) ^ /usr/include/c++/4.8/bits/stl_stack.h:191:7: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::stack<int>::value_type&& {aka int&&}' depou.cpp:25:15: error: statement cannot resolve address of overloaded function b.pop; ^ depou.cpp:26:10: error: 'nr' was not declared in this scope nr++; ^ depou.cpp:28:18: error: invalid use of member function (did you forget the '()' ?) if(a.empty==0 && c.empty==0) ^ depou.cpp:28:32: error: invalid use of member function (did you forget the '()' ?) if(a.empty==0 && c.empty==0) ^ depou.cpp:29:22: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator+' if(a.top==c.top+1) ^ depou.cpp:31:22: error: no matching function for call to 'std::stack<int>::push(<unresolved overloaded function type>)' c.push(a.top); ^ depou.cpp:31:22: note: candidates are: In file included from /usr/include/c++/4.8/stack:61:0, from depou.cpp:2: /usr/include/c++/4.8/bits/stl_stack.h:186:7: note: void std::stack<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; std::stack<_Tp, _Sequence>::value_type = int] push(const value_type& __x) ^ /usr/include/c++/4.8/bits/stl_stack.h:186:7: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const value_type& {aka const int&}' /usr/include/c++/4.8/bits/stl_stack.h:191:7: note: void std::stack<_Tp, _Sequence>::push(std::stack<_Tp, _Sequence>::value_type&&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; std::stack<_Tp, _Sequence>::value_type = int] push(value_type&& __x) ^ /usr/include/c++/4.8/bits/stl_stack.h:191:7: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::stack<int>::value_type&& {aka int&&}' depou.cpp:32:15: error: statement cannot resolve address of overloaded function a.pop; ^ depou.cpp:33:10: error: 'nr' was not declared in this scope nr++; ^ depou.cpp:35:24: error: invalid use of member function (did you forget the '()' ?) else if( a.empty==0) ^ depou.cpp:37:25: error: no matching function for call to 'std::stack<int>::push(<unresolved overloaded function type>)' b.push(a.top); ^ depou.cpp:37:25: note: candidates are: In file included from /usr/include/c++/4.8/stack:61:0, from depou.cpp:2: /usr/include/c++/4.8/bits/stl_stack.h:186:7: note: void std::stack<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; std::stack<_Tp, _Sequence>::value_type = int] push(const value_type& __x) ^ /usr/include/c++/4.8/bits/stl_stack.h:186:7: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const value_type& {aka const int&}' /usr/include/c++/4.8/bits/stl_stack.h:191:7: note: void std::stack<_Tp, _Sequence>::push(std::stack<_Tp, _Sequence>::value_type&&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; std::stack<_Tp, _Sequence>::value_type = int] push(value_type&& __x) ^ /usr/include/c++/4.8/bits/stl_stack.h:191:7: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::stack<int>::value_type&& {aka int&&}' depou.cpp:38:18: error: statement cannot resolve address of overloaded function a.pop; ^ depou.cpp:39:13: error: 'nr' was not declared in this scope nr++; ^ depou.cpp:28:8: warning: suggest explicit braces to avoid ambiguous 'else' [-Wparentheses] if(a.empty==0 && c.empty==0) ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Depou 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ă.