package main import ( "bufio" "fmt" "os" "strconv" ) func configure(scanner *bufio.Scanner) { scanner.Split(bufio.ScanWords) scanner.Buffer(make([]byte, 1000005), 1000005) } func getNextString(scanner *bufio.Scanner) string { scanned := scanner.Scan() if !scanned { panic("scan failed") } return scanner.Text() } func getNextInt(scanner *bufio.Scanner) int { i, _ := strconv.Atoi(getNextString(scanner)) return i } func getNextInt64(scanner *bufio.Scanner) int64 { i, _ := strconv.ParseInt(getNextString(scanner), 10, 64) return i } func getNextFloat64(scanner *bufio.Scanner) float64 { i, _ := strconv.ParseFloat(getNextString(scanner), 64) return i } func main() { fp := os.Stdin wfp := os.Stdout extra := 0 if os.Getenv("I") == "IronMan" { fp, _ = os.Open(os.Getenv("END_GAME")) extra = 100 } scanner := bufio.NewScanner(fp) configure(scanner) writer := bufio.NewWriter(wfp) defer func() { r := recover() if r != nil { fmt.Fprintln(writer, r) } writer.Flush() }() solve(scanner, writer) for i := 0; i < extra; i++ { fmt.Fprintln(writer, "-----------------------------------") solve(scanner, writer) } } func solve(scanner *bufio.Scanner, writer *bufio.Writer) { n := getNextInt(scanner) a := getNextInt(scanner) b := getNextInt(scanner) xx := make([]int, n) for i := 0; i < n; i++ { xx[i] = getNextInt(scanner) } uf := make([]int, n) for i := 0; i < n; i++ { uf[i] = i } pr := 1 for i := 0; i < n; i++ { l := lower(xx[i]+a, xx) r := lower(xx[i]+b+1, xx) if l >= r { continue } ri := root(i, uf) rj := root(l, uf) if ri < rj { uf[rj] = ri } else { uf[ri] = rj } for j := max(l, pr); j < r; j++ { uf[j] = uf[i] } pr = max(r, pr) } cc := make([]int, n) for i := 0; i < n; i++ { cc[root(i, uf)]++ } for i := 0; i < n; i++ { fmt.Fprintln(writer, cc[root(i, uf)]) } } func lower(x int, xx []int) int { n := len(xx) l := -1 r := n for l+1 < r { m := (l + r) >> 1 if xx[m] < x { l = m continue } r = m } return r } func root(i int, uf []int) int { if i == uf[i] { return i } uf[i] = root(uf[i], uf) return uf[i] } func max(a, b int) int { if a > b { return a } return b }