CSES - Datatähti 2024 alku - Results
Submission details
Task:Monistus
Sender:snowflake
Submission time:2023-11-09 11:22:04 +0200
Language:C++ (C++17)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'std::string Boo(std::string)':
input/code.cpp:17:32: error: no match for 'operator+' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'int')
   17 |             s.replace(loo, soo + 1, soo + soo);
      |                            ~~~ ^ ~
      |                            |     |
      |                            |     int
      |                            std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/11/bits/stl_algobase.h:67,
                 from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from input/code.cpp:1:
/usr/include/c++/11/bits/stl_iterator.h:568:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename std::reverse_iterator<_Iterator>::differ...

Code

#include <iostream>
#include <string>
using namespace std;


string Boo(string soe)
{
    string s = soe;

    int loo = 0;
    while (loo < (int)s.length())
    {
        if (isdigit(s[loo]))
        {
            int cn = s[loo] - '0';
            string soo = s.substr(loo + 1, cn);
            s.replace(loo, soo + 1, soo + soo);
        }
        else
        {
            loo++;
        }
    }


    return s;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string soho;
    cin >> soho;

    string deedee = Boo(soho);


    cout << deedee;

    return 0;
}

// >
// 82silisko
// 2silisko2silisko
// sisilisko2silisko
// sisiliskosisilisko
// sisiliskosisilisko