#3991
ModificaParanteze
Fie un șir de paranteze rotunde, deschise sau închise. Putem efectua de câte ori dorim operația de transformare a unei paranteze deschise într-una închisă sau invers. Să se determine numărul minim de operații necesare transformării secvenței inițiale într-una corect parantezată. Dacă acest lucru nu este posibil, se va afișa -1
.
Folclorul informatic
Problema | ModificaParanteze | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #54125831 | Utilizator | |
Fișier | modificaparanteze.cpp | Dimensiune | 285 B |
Data încărcării | 20 Noiembrie 2024, 11:49 | Scor / rezultat | Eroare de compilare |
modificaparanteze.cpp: In function 'int main()': modificaparanteze.cpp:14:31: error: no match for 'operator-' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'int') if((cnt1-cnt2)%2==1) cout -1; ^ modificaparanteze.cpp:14:31: note: candidates are: In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, 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 modificaparanteze.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:327:5: note: template<class _Iterator> typename std::reverse_iterator<_Iterator>::difference_type std::operator-(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&) operator-(const reverse_iterator<_Iterator>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:327:5: note: template argument deduction/substitution failed: modificaparanteze.cpp:14:32: note: 'std::ostream {aka std::basic_ostream<char>}' is not derived from 'const std::reverse_iterator<_Iterator>' if((cnt1-cnt2)%2==1) cout -1; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, 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 modificaparanteze.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:379:5: note: template<class _IteratorL, class _IteratorR> decltype ((__y.base() - __x.base())) std::operator-(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&) operator-(const reverse_iterator<_IteratorL>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:379:5: note: template argument deduction/substitution failed: modificaparanteze.cpp:14:32: note: 'std::ostream {aka std::basic_ostream<char>}' is not derived from 'const std::reverse_iterator<_Iterator>' if((cnt1-cnt2)%2==1) cout -1; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, 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 modificaparanteze.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:1104:5: note: template<class _IteratorL, class _IteratorR> decltype ((__x.base() - __y.base())) std::operator-(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&) operator-(const move_iterator<_IteratorL>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:1104:5: note: template argument deduction/substitution failed: modificaparanteze.cpp:14:32: note: 'std::ostream {aka std::basic_ostream<char>}' is not derived from 'const std::move_iterator<_Iterator>' if((cnt1-cnt2)%2==1) cout -1; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, 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 modificaparanteze.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:1111:5: note: template<class _Iterator> decltype ((__x.base() - __y.base())) std::operator-(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&) operator-(const move_iterator<_Iterator>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:1111:5: note: template argument deduction/substitution failed: modificaparanteze.cpp:14:32: note: 'std::ostream {aka std::basic_ostream<char>}' is not derived from 'const std::move_iterator<_Iterator>' if((cnt1-cnt2)%2==1) cout -1; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema ModificaParanteze 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ă.