本文为离散化板子,每次先 reset,然后一个一个加入元素,然后用 get 得到离散化之后的替换( 开头)。
struct lsh
{
int t,g[N];
void reset()
{
t=0;
}
void add(int x)
{
g[t++]=x;
}
void calc()
{
sort(g,g+t);
t=unique(g,g+t)-g;
}
void get(int &x)
{
x=lower_bound(g,g+t,x)-g;
}
}L;