use std::collections::{BTreeSet, HashMap, HashSet}; fn main() { proconio::input! { n: usize, a: i64, b: i64, x: [i64; n], } let mut x = x.into_iter().enumerate().collect::>(); let mut groups = vec![]; loop { let Some(station) = x.pop() else { break; }; let mut stations = vec![station]; let mut group = vec![station]; while !stations.is_empty() { let Some(station) = stations.pop() else { break; }; let first = x.partition_point(|x| x.1 < station.1 + a); let last = x.partition_point(|x| x.1 <= station.1 + b); // eprintln!( // "plus {station:?}: {} {}, {:?}, {}", // first, // last, // &x[first..last], // stations.len() // ); group.extend(x.drain(first..last).inspect(|x| { stations.push(*x); })); let first = x.partition_point(|x| x.1 < station.1 - b); let last = x.partition_point(|x| x.1 <= station.1 - a); // eprintln!( // "minus {station:?}: {} {} {:?}, {}", // first, // last, // &x[first..last], // stations.len() // ); group.extend(x.drain(first..last).inspect(|x| { stations.push(*x); })); } groups.push(group); } //eprintln!("{:?}", groups); let mut v = vec![u64::MAX; n]; for group in groups { for station in group.iter() { v[station.0] = group.len() as u64; } } for i in 0..n { println!("{}", v[i]); } }