座標圧縮
(data-structure/compress.hpp)
- View this file on GitHub
- Last update: 2025-10-10 17:35:46+09:00
- Include:
#include "data-structure/compress.hpp"
座標圧縮をする.
-
buildで構築 -
[]で座標圧縮後の要素にアクセス -
findで座標圧縮後の index を検索, lower bound を返す
Code
#pragma once
template <class T>
struct Compress : vector<T> {
void build() {
sort(begin(), end());
erase(unique(begin(), end()), end());
}
int find(T v) const { return int(lower_bound(begin(), end(), v) - begin()); }
};
/**
* @brief 座標圧縮
* @docs docs/data-structure/compress.md
*/#line 2 "data-structure/compress.hpp"
template <class T>
struct Compress : vector<T> {
void build() {
sort(begin(), end());
erase(unique(begin(), end()), end());
}
int find(T v) const { return int(lower_bound(begin(), end(), v) - begin()); }
};
/**
* @brief 座標圧縮
* @docs docs/data-structure/compress.md
*/