#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; struct UnionFind { private: vector child, tree; vector> list; public: //頂点数v UnionFind(ll v) { tree.resize(v); list.resize(v); for(ll i = 0; i < v; i++) { tree[i] = i; list[i].push_back(i); } } //木の根を求める ll root(ll x) { if(x == tree[x]) { for(ll i = 0; i < child.size(); i++) { tree[child[i]] = x; } child.clear(); return x; } else { child.push_back(x); return x = root(tree[x]); } } // xの所属するグループの大きさ ll size(ll x) { return list[root(x)].size(); } vector nodes(ll no) { return list[root(no)]; } // xとyの集合を合わせる bool unit(ll x, ll y) { x = root(x); y = root(y); if(x == y) { return false; } if(list[x].size() < list[y].size()) { swap(x, y); } for(int no : list[y]) { list[x].emplace_back(no); } tree[y] = x; return true; } // xとyが同じグループに所属するか bool isUnit(ll x, ll y) { return root(x) == root(y); } }; int main() { int n, a, b; cin >> n >> a >> b; vector x(n); for(int i = 0; i < n; i++) { cin >> x[i]; } UnionFind uf(n); for(int i = 0; i < n; i++) { auto check1 = lower_bound(x.begin(), x.end(), x[i] + a); auto check2 = upper_bound(x.begin(), x.end(), x[i] + b); int l, r; if(check1 != x.end()) { l = distance(x.begin(), check1); r = distance(x.begin(), check2); for(int j = l; j < r; j++) { uf.unit(i, j); } } } for(int i = 0; i < n; i++) { cout << uf.size(i) << endl; } return 0; }