library

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

View the Project on GitHub maspypy/library

:heavy_check_mark: string/run_length.hpp

Required by

Verified with

Code

template <typename STRING = string, typename CHAR = char>
vc<pair<CHAR, int>> run_length(STRING& S) {
  vc<pair<CHAR, int>> res;
  for (auto&& x: S) {
    if (res.empty() || res.back().fi != x) { res.emplace_back(x, 0); }
    res.back().se++;
  }
  return res;
}
#line 1 "string/run_length.hpp"
template <typename STRING = string, typename CHAR = char>
vc<pair<CHAR, int>> run_length(STRING& S) {
  vc<pair<CHAR, int>> res;
  for (auto&& x: S) {
    if (res.empty() || res.back().fi != x) { res.emplace_back(x, 0); }
    res.back().se++;
  }
  return res;
}
Back to top page