void main() { problem(); } void problem() { auto N = scan!int; auto A = scan!long; auto B = scan!long; auto S = scan!long(N); const LEFT_LIMIT = 0; const RIGHT_LIMIT = S[$ - 1]; int[] Z = new int[RIGHT_LIMIT + 1]; auto ans = new long[N]; void solve() { foreach(i; 0..N-1) Z[S[i] .. S[i + 1] ] = i + 1; Z[$-1] = N; foreach(stationIndex; 0..N) { if (ans[stationIndex] > 0) continue; bool[int] visits = [stationIndex: true]; bool[int] newVisits = visits; while(true) { bool[int] nextVisits; foreach(v; newVisits.keys) { visits[v] = true; auto right_s = S[v] + A > RIGHT_LIMIT ? RIGHT_LIMIT : S[v] + A; auto right_e = S[v] + B > RIGHT_LIMIT ? RIGHT_LIMIT : S[v] + B; [right_s, right_e].deb; [Z[right_s], Z[right_e]].deb; foreach(n; Z[right_s] .. Z[right_e]) { if (!(n in visits)) nextVisits[n] = true; } auto left_s = S[v] - B < LEFT_LIMIT ? LEFT_LIMIT : S[v] - B; auto left_e = S[v] - A < LEFT_LIMIT ? LEFT_LIMIT : S[v] - A; [left_s, left_e].deb; [Z[left_s], Z[left_e]].deb; foreach(n; Z[left_s] .. Z[left_e]) { if (!(n in visits)) nextVisits[n] = true; } } if (nextVisits.length == 0) break; newVisits = nextVisits; newVisits.deb; } visits.deb; const reach = visits.length; foreach(v; visits.keys) { ans[v] = reach; } } ans.each!(a => a.writeln); } solve(); } // ---------------------------------------------- import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric; T[][] combinations(T)(T[] s, in int m) { if (!m) return [[]]; if (s.empty) return []; return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); } string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; } T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; } void deb(T ...)(T t){ debug writeln(t); } alias Point = Tuple!(long, "x", long, "y"); // -----------------------------------------------