This documentation is automatically generated by online-judge-tools/verification-helper
#include "kpr/algorithm/compress.hpp"#pragma once
#include <algorithm>
#include <iterator>
#include <unordered_map>
#include <vector>
#include "../function/compare.hpp"
namespace kpr {
// 座標圧縮
[[maybe_unused]] inline constexpr struct {
template<class T, class Compare = Less, class Container = std::unordered_map<typename std::iterator_traits<T>::value_type, KYOPRO_BASE_INT>>
auto operator ()(T first, T last, Compare comp = {}) const {
std::vector<typename Container::key_type> a(first, last);
std::sort(a.begin(), a.end(), comp);
auto itr = unique(a.begin(), a.end());
Container mem;
int cnt = -1;
for (auto i = std::begin(a); i != itr; ++i) mem[*i] = ++cnt;
return mem;
}
} compress;
} // namespace kpr#line 2 "kpr/algorithm/compress.hpp"
#include <algorithm>
#include <iterator>
#include <unordered_map>
#include <vector>
#line 2 "kpr/function/compare.hpp"
namespace kpr {
// operator =で比較
struct Equal {
template<class T>
constexpr bool operator()(const T& x, const T& y) const noexcept(noexcept(x == y)) {
return x == y;
}
};
// operator !=で比較
struct NotEqual {
template<class T>
constexpr bool operator()(const T& x, const T& y) const noexcept(noexcept(x != y)) {
return x != y;
}
};
// operator <の関数クラス
struct Less {
template<class T>
constexpr bool operator()(const T& x, const T& y) const noexcept(noexcept(x < y)) {
return x < y;
}
};
// operator <=の関数クラス
struct LessEqual {
template<class T>
constexpr bool operator()(const T& x, const T& y) const noexcept(noexcept(x <= y)) {
return x <= y;
}
};
// operator >の関数クラス
struct Greater {
template<class T>
constexpr bool operator()(const T& x, const T& y) const noexcept(noexcept(x > y)) {
return x > y;
}
};
// operator >=の関数クラス
struct GreaterEqual {
template<class T>
constexpr bool operator()(const T& x, const T& y) const noexcept(noexcept(x >= y)) {
return x >= y;
}
};
} // namespace kpr
#line 7 "kpr/algorithm/compress.hpp"
namespace kpr {
// 座標圧縮
[[maybe_unused]] inline constexpr struct {
template<class T, class Compare = Less, class Container = std::unordered_map<typename std::iterator_traits<T>::value_type, KYOPRO_BASE_INT>>
auto operator ()(T first, T last, Compare comp = {}) const {
std::vector<typename Container::key_type> a(first, last);
std::sort(a.begin(), a.end(), comp);
auto itr = unique(a.begin(), a.end());
Container mem;
int cnt = -1;
for (auto i = std::begin(a); i != itr; ++i) mem[*i] = ++cnt;
return mem;
}
} compress;
} // namespace kpr