CSES - Datatähti 2024 alku - Results
Submission details
Task:Monistus
Sender:Miika
Submission time:2023-10-30 10:27:02 +0200
Language:C++ (C++17)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:23:28: error: 'accumulate' is not a member of 'std'
   23 |             tempstr = std::accumulate(strl, strl + z, std::string(""));
      |                            ^~~~~~~~~~

Code

#include <iostream>
#include <regex>
#include <string>

int main() {
    std::string i;
    std::getline(std::cin, i);
    std::string tempstr = ".";
    while (tempstr != "") {
        int z = 0;
        tempstr = "";
        std::regex regex("\\d");
        std::smatch match;
        if (std::regex_search(i, match, regex)) {
            z = std::stoi(match.str());
            int f = match.position();
            i.erase(f, 1);
            std::string strl[z];
            for (int item = 0; item < z; item++) {
                strl[item] = std::string(1, i[item + f]);
                z -= 1;
            }
            tempstr = std::accumulate(strl, strl + z, std::string(""));
            i.insert(f, tempstr);
        }
    }
    std::cout << i << std::endl;
    return 0;
}