/* -*- coding: utf-8 -*- * * 1170.cc: No.1170 Never Want to Walk - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 200000; /* typedef */ struct UFT { int links[MAX_N], ranks[MAX_N], sizes[MAX_N]; UFT() {} void init(int n) { for (int i = 0; i < n; i++) links[i] = i, ranks[i] = sizes[i] = 1; } int root(int i) { int i0 = i; while (links[i0] != i0) i0 = links[i0]; return (links[i] = i0); } int rank(int i) { return ranks[root(i)]; } int size(int i) { return sizes[root(i)]; } bool same(int i, int j) { return root(i) == root(j); } int merge(int i0, int i1) { int r0 = root(i0), r1 = root(i1), mr; if (r0 == r1) return r0; if (ranks[r0] == ranks[r1]) { links[r1] = r0; sizes[r0] += sizes[r1]; ranks[r0]++; mr = r0; } else if (ranks[r0] > ranks[r1]) { links[r1] = r0; sizes[r0] += sizes[r1]; mr = r0; } else { links[r0] = r1; sizes[r1] += sizes[r0]; mr = r1; } return mr; } }; /* global variables */ int xs[MAX_N]; UFT uft; /* subroutines */ /* main */ int main() { int n, a, b; scanf("%d%d%d", &n, &a, &b); for (int i = 0; i < n; i++) scanf("%d", xs + i); uft.init(n); for (int i = 0, j = 0, k = 0; i < n; i++) { while (j < n && xs[i] + a > xs[j]) j++; if (j >= n) break; if (k < j) k = j; while (k < n && xs[i] + b >= xs[k]) { uft.merge(j, k); k++; } if (j < k) uft.merge(i, j); //printf("%d-(%d,%d)\n", i, j, k); } for (int i = 0; i < n; i++) printf("%d\n", uft.size(i)); return 0; }