#if loc||local #define _GLIBCXX_DEBUG #endif #include using namespace std; #define rep(i,n) for(ll i=0;i<(n);++i) using ll = int_fast64_t; using pll = pair; constexpr ll INF = 1LL<<60; constexpr ll MOD = 1e9+7; template bool chmax(T &a,const T &b){if(a bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;} #if loc||local templatevoid dump(T&& t){cerr< void dump(T&& h, Ts&&... t){cerr<(t)...);} #else void dump(){} template void dump(T&& h, Ts&&... t){} #endif template istream &operator>>(istream&is,vector&v){for(auto &elemnt:v)is>>elemnt;return is;} template istream &operator>>(istream&is,pair&p){is>>p.first>>p.second;return is;} template ostream &operator<<(ostream& os,vectorconst& v){for(auto const& vi:v)os< ostream &operator<<(ostream& os,pairconst& p){os<vector vec(size_t a){return vector(a);} templateauto vec(size_t a, Ts... ts){return vector(ts...))>(a, vec(ts...));} struct union_find{ size_t n; vector par; size_t group; union_find(){} union_find(size_t _n):n(_n),group(_n){ par.resize(n,-1); } void reset(size_t _n){ n = _n; group = n; par.clear(); par.resize(n,-1); } int root(int k){ if(par[k]<0)return k; return par[k] = root(par[k]); } int size(int k){ k = root(k); return -par[k]; } auto operator[](int k){ return size(k); } bool unite(int a,int b){ a = root(a); b = root(b); if(a==b)return false; if(size(a)>n>>a>>b; vector x(n); cin>>x; union_find uni(n); vector visited(n); set st; rep(i,n)st.emplace(x[i],i); st.emplace(INF,INF); auto bfs = [&](int s){ queue que; que.emplace(s); while(!que.empty()){ int cur = que.front(); que.pop(); if(visited[cur])continue; visited[cur] = 1; auto itr = st.lower_bound({x[cur]+a,-1}); while(1){ auto [xi,to] = *itr; if(xi>x[cur]+b)break; que.emplace(to); uni.unite(cur,to); itr = st.erase(itr); } itr = st.lower_bound({x[cur]-b,-1}); while(1){ auto [xi,to] = *itr; if(a>x[cur]-xi)break; que.emplace(to); uni.unite(cur,to); itr = st.erase(itr); } } }; rep(i,n)if(!visited[i])bfs(i); rep(i,n)cout<