結果
| 問題 |
No.1170 Never Want to Walk
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-06 10:13:49 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,351 bytes |
| コンパイル時間 | 24,206 ms |
| コンパイル使用メモリ | 388,556 KB |
| 実行使用メモリ | 20,204 KB |
| 最終ジャッジ日時 | 2024-08-06 10:14:18 |
| 合計ジャッジ時間 | 19,069 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 TLE * 1 -- * 11 |
コンパイルメッセージ
warning: unused imports: `HashMap`, `HashSet`
--> src/main.rs:1:34
|
1 | use std::collections::{BTreeSet, HashMap, HashSet};
| ^^^^^^^ ^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
ソースコード
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::<Vec<_>>();
let mut mushozoku = x.iter().copied().collect::<BTreeSet<_>>();
let mut groups = vec![];
loop {
let Some(station) = mushozoku.pop_first() else {
break;
};
let mut stations = BTreeSet::new();
stations.insert(station);
let mut group = BTreeSet::new();
group.insert(station);
while !stations.is_empty() {
let Some(station) = stations.pop_first() 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()
// );
let append = x
.drain(first..last)
.filter(|x| !group.contains(x))
.inspect(|x| {
stations.insert(*x);
mushozoku.remove(x);
})
.collect::<Vec<_>>();
group.extend(append);
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()
// );
let append = x
.drain(first..last)
.filter(|x| !group.contains(x))
.inspect(|x| {
stations.insert(*x);
mushozoku.remove(x);
})
.collect::<Vec<_>>();
group.extend(append);
}
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]);
}
}