Detalii evaluare #51528400

Rezumat problemă

#970 Gen

Pe planeta Marte, marţienii folosesc în calculele aritmetice doar cifrele 0, 1, 2 şi 3. Ei au inventat un nou sistem binar de numeraţie. Pornind de la numărul 23, ei generează numere binare speciale aplicând de un număr finit de ori regulile din tabelul de mai jos:

  1. Cifra 2 se poate înlocui cu succesiunea: 12
  2. Cifra 3 se poate înlocui cu succesiunea: 03
  3. Cifra 2 se poate înlocui cu succesiunea: 01
  4. Cifra 3 se poate înlocui cu succesiunea: 10

Marţienii au început să genereze un astfel de număr, aplicând succesiv (în această ordine): de n ori regula 1); de k ori regula 2); o singură dată regula 3) şi o singură dată regula 4). Nefiind atenţi, ei nu au reuşit să ducă la capăt generarea şi au nevoie de ajutor. Ajutaţi-i să genereze numărul binar dorit.

Scrieţi un program care citeşte numerele naturale nenule n şi k şi care afişează numărul binar obţinut în urma aplicării succesive a regulilor cerute de marţieni.

Olimpiada de Informatică, etapa pe sector, Bucureşti, 2007, clasa a VI-a

Detalii

Problema Gen Operații I/O tastatură/ecran
Limita timp 1 secunde Limita memorie Total: 2 MB / Stivă 1 MB
Id soluție #51528400 Utilizator Daus Ionut (ionutdaus)
Fișier gen.cpp Dimensiune 569 B
Data încărcării 05 Iulie 2024, 12:25 Scor / rezultat Eroare de compilare

Evaluare


Mesaj compilare

gen.cpp: In function 'int main()':
gen.cpp:15:56: error: no matching function for call to 'regex_replace(std::string&, std::regex, const char [3])'
         number = regex_replace(number, regex("2"), "12");

                                                        ^
gen.cpp:15:56: note: candidates are:
In file included from /usr/include/c++/4.8/regex:62:0,
                 from gen.cpp:3:
/usr/include/c++/4.8/bits/regex.h:2162:5: note: template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type)
     regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
     ^
/usr/include/c++/4.8/bits/regex.h:2162:5: note:   template argument deduction/substitution failed:
gen.cpp:15:56: note:   deduced conflicting types for parameter '_Bi_iter' ('std::basic_regex<char>' and 'const char*')
         number = regex_replace(number, regex("2"), "12");

                                                        ^
In file included from /usr/include/c++/4.8/regex:62:0,
                 from gen.cpp:3:
/usr/include/c++/4.8/bits/regex.h:2182:5: note: template<class _Rx_traits, class _Ch_type> std::basic_string<_Ch_type> std::regex_replace(const std::basic_string<_Ch_type>&, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type)
     regex_replace(const basic_string<_Ch_type>& __s,
     ^
/usr/include/c++/4.8/bits/regex.h:2182:5: note:   template argument deduction/substitution failed:
gen.cpp:15:56: note:   mismatched types 'const std::basic_string<_Ch_type>' and 'const char [3]'
         number = regex_replace(number, regex("2"), "12");

                                                        ^
gen.cpp:19:56: error: no matching function for call to 'regex_replace(std::string&, std::regex, const char [3])'
         number = regex_replace(number, regex("3"), "03");

                                                        ^
gen.cpp:19:56: note: candidates are:
In file included from /usr/include/c++/4.8/regex:62:0,
                 from gen.cpp:3:
/usr/include/c++/4.8/bits/regex.h:2162:5: note: template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type)
     regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
     ^
/usr/include/c++/4.8/bits/regex.h:2162:5: note:   template argument deduction/substitution failed:
gen.cpp:19:56: note:   deduced conflicting types for parameter '_Bi_iter' ('std::basic_regex<char>' and 'const char*')
         number = regex_replace(number, regex("3"), "03");

                                                        ^
In file included from /usr/include/c++/4.8/regex:62:0,
                 from gen.cpp:3:
/usr/include/c++/4.8/bits/regex.h:2182:5: note: template<class _Rx_traits, class _Ch_type> std::basic_string<_Ch_type> std::regex_replace(const std::basic_string<_Ch_type>&, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type)
     regex_replace(const basic_string<_Ch_type>& __s,
     ^
/usr/include/c++/4.8/bits/regex.h:2182:5: note:   template argument deduction/substitution failed:
gen.cpp:19:56: note:   mismatched types 'const std::basic_string<_Ch_type>' and 'const char [3]'
         number = regex_replace(number, regex("3"), "03");

                                                        ^
gen.cpp:21:52: error: no matching function for call to 'regex_replace(std::string&, std::regex, const char [3])'
     number = regex_replace(number, regex("2"), "01");

                                                    ^
gen.cpp:21:52: note: candidates are:
In file included from /usr/include/c++/4.8/regex:62:0,
                 from gen.cpp:3:
/usr/include/c++/4.8/bits/regex.h:2162:5: note: template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type)
     regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
     ^
/usr/include/c++/4.8/bits/regex.h:2162:5: note:   template argument deduction/substitution failed:
gen.cpp:21:52: note:   deduced conflicting types for parameter '_Bi_iter' ('std::basic_regex<char>' and 'const char*')
     number = regex_replace(number, regex("2"), "01");

                                                    ^
In file included from /usr/include/c++/4.8/regex:62:0,
                 from gen.cpp:3:
/usr/include/c++/4.8/bits/regex.h:2182:5: note: template<class _Rx_traits, class _Ch_type> std::basic_string<_Ch_type> std::regex_replace(const std::basic_string<_Ch_type>&, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type)
     regex_replace(const basic_string<_Ch_type>& __s,
     ^
/usr/include/c++/4.8/bits/regex.h:2182:5: note:   template argument deduction/substitution failed:
gen.cpp:21:52: note:   mismatched types 'const std::basic_string<_Ch_type>' and 'const char [3]'
     number = regex_replace(number, regex("2"), "01");

                                                    ^
gen.cpp:22:52: error: no matching function for call to 'regex_replace(std::string&, std::regex, const char [3])'
     number = regex_replace(number, regex("3"), "10");

                                                    ^
gen.cpp:22:52: note: candidates are:
In file included from /usr/include/c++/4.8/regex:62:0,
                 from gen.cpp:3:
/usr/include/c++/4.8/bits/regex.h:2162:5: note: template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type)
     regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
     ^
/usr/include/c++/4.8/bits/regex.h:2162:5: note:   template argument deduction/substitution failed:
gen.cpp:22:52: note:   deduced conflicting types for parameter '_Bi_iter' ('std::basic_regex<char>' and 'const char*')
     number = regex_replace(number, regex("3"), "10");

                                                    ^
In file included from /usr/include/c++/4.8/regex:62:0,
                 from gen.cpp:3:
/usr/include/c++/4.8/bits/regex.h:2182:5: note: template<class _Rx_traits, class _Ch_type> std::basic_string<_Ch_type> std::regex_replace(const std::basic_string<_Ch_type>&, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type)
     regex_replace(const basic_string<_Ch_type>& __s,
     ^
/usr/include/c++/4.8/bits/regex.h:2182:5: note:   template argument deduction/substitution failed:
gen.cpp:22:52: note:   mismatched types 'const std::basic_string<_Ch_type>' and 'const char [3]'
     number = regex_replace(number, regex("3"), "10");

                                                    ^

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 Gen 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ă.