rcpl

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub ruthen71/rcpl

:warning: Run Length Encoding (ランレングス圧縮)
(string/run_length_encoding.hpp)

Code

#pragma once

std::vector<std::pair<char, int>> run_length_encoding(std::string &S) {
    assert(S.size() > 0);
    std::vector<std::pair<char, int>> res = {{S.front(), 0}};
    for (auto &si : S) {
        if (si != res.back().first) {
            res.push_back({si, 0});
        }
        res.back().second++;
    }
    return res;
}
#line 2 "string/run_length_encoding.hpp"

std::vector<std::pair<char, int>> run_length_encoding(std::string &S) {
    assert(S.size() > 0);
    std::vector<std::pair<char, int>> res = {{S.front(), 0}};
    for (auto &si : S) {
        if (si != res.back().first) {
            res.push_back({si, 0});
        }
        res.back().second++;
    }
    return res;
}
Back to top page