#2187
Ana şi Bogdan au inventat un nou joc, pe care l-au numit Expand. Jocul are N cartonaşe, pe fiecare cartonaş fiind scrisă o literă şi o secvenţă formată din două sau trei litere. O mutare constă în utilizarea unui cartonaş prin care o singură apariţie a literei scrisă pe cartonaş va fi înlocuită în cuvântul curent cu secvenţa corespunzătoare de pe cartonaş. Apoi cartonaşul este repus în joc, astfel că acelaşi cartonaş poate fi utilizat de oricâte ori. Iniţial Ana alege o literă şi un cuvânt. Bogdan trebuie să obţină cuvântul spus de Ana, plecând de la litera respectivă, efectuând un număr minim de mutări. Scrieţi un program care determină numărul minim de mutări necesare pentru a obţine din litera aleasă de Ana cuvântul dat.
Olimpiada Municipala de Informatica, Iasi, 2017
| Problema | expand | Operații I/O |
expand.in/expand.out
|
|---|---|---|---|
| Limita timp | 2 secunde | Limita memorie |
Total: 512 MB
/
Stivă 8 MB
|
| Id soluție | #59100658 | Utilizator | |
| Fișier | expand.cpp | Dimensiune | 1.45 KB |
| Data încărcării | 17 Septembrie 2025, 16:26 | Scor/rezultat | Eroare de compilare |
expand.cpp: In function 'void bfs()': expand.cpp:40:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < curr.size(); i++) ^ expand.cpp:49:40: error: no matching function for call to 'std::basic_string<char>::append(std::string&, int)' next.append(curr, i + 1); ^ expand.cpp:49:40: note: candidates are: In file included from /usr/include/c++/4.8/string:52:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from expand.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:973:7: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::append(const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>] append(const basic_string& __str); ^ /usr/include/c++/4.8/bits/basic_string.h:973:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/4.8/bits/basic_string.h:989:7: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::append(const std::basic_string<_CharT, _Traits, _Alloc>&, std::basic_string<_CharT, _Traits, _Alloc>::size_type, std::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int] append(const basic_string& __str, size_type __pos, size_type __n); ^ /usr/include/c++/4.8/bits/basic_string.h:989:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/4.8/bits/basic_string.h:998:7: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::append(const _CharT*, std::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int] append(const _CharT* __s, size_type __n); ^ /usr/include/c++/4.8/bits/basic_string.h:998:7: note: no known conversion for argument 1 from 'std::string {aka std::basic_string<char>}' to 'const char*' /usr/include/c++/4.8/bits/basic_string.h:1006:7: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::append(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>] append(const _CharT* __s) ^ /usr/include/c++/4.8/bits/basic_string.h:1006:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/4.8/bits/basic_string.h:1021:7: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::append(std::basic_string<_CharT, _Traits, _Alloc>::size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int] append(size_type __n, _CharT __c); ^ /usr/include/c++/4.8/bits/basic_string.h:1021:7: note: no known conversion for argument 1 from 'std::string {aka std::basic_string<char>}' to 'std::basic_string<char>::size_type {aka unsigned int}' /usr/include/c++/4.8/bits/basic_string.h:1030:7: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::append(std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>] append(initializer_list<_CharT> __l) ^ /usr/include/c++/4.8/bits/basic_string.h:1030:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/4.8/bits/basic_string.h:1044:9: note: template<class _InputIterator> std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::append(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>] append(_InputIterator __first, _InputIterator __last) ^ /usr/include/c++/4.8/bits/basic_string.h:1044:9: note: template argument deduction/substitution failed: expand.cpp:49:40: note: deduced conflicting types for parameter '_InputIterator' ('std::basic_string<char>' and 'int') next.append(curr, i + 1); ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema expand 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ă.