algo

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

View the Project on GitHub dnx04/algo

:heavy_check_mark: misc/Compressor.h

Required by

Verified with

Code

template <class T>
vi compressor(vector<T>& v) {
  auto cv = v;
  sort(all(cv));
  cv.erase(unique(all(cv)), cv.end());
  for (auto& e : v) e = lower_bound(all(cv), e) - cv.begin();
  return v;
}
#line 1 "misc/Compressor.h"
template <class T>
vi compressor(vector<T>& v) {
  auto cv = v;
  sort(all(cv));
  cv.erase(unique(all(cv)), cv.end());
  for (auto& e : v) e = lower_bound(all(cv), e) - cv.begin();
  return v;
}
Back to top page