結果

問題 No.1170 Never Want to Walk
ユーザー tabataba
提出日時 2024-08-06 09:57:31
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 2,403 bytes
コンパイル時間 29,801 ms
コンパイル使用メモリ 377,780 KB
実行使用メモリ 28,944 KB
最終ジャッジ日時 2024-08-06 09:58:10
合計ジャッジ時間 35,368 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,752 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 4 ms
5,376 KB
testcase_21 WA -
testcase_22 AC 44 ms
5,376 KB
testcase_23 AC 13 ms
5,376 KB
testcase_24 AC 45 ms
5,376 KB
testcase_25 AC 46 ms
5,376 KB
testcase_26 AC 26 ms
5,376 KB
testcase_27 AC 562 ms
15,096 KB
testcase_28 AC 492 ms
14,988 KB
testcase_29 AC 468 ms
15,304 KB
testcase_30 AC 482 ms
15,376 KB
testcase_31 AC 453 ms
14,896 KB
testcase_32 TLE -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused imports: `HashMap`, `HashSet`
 --> src/main.rs:1:34
  |
1 | use std::collections::{BTreeSet, HashMap, HashSet};
  |                                  ^^^^^^^  ^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

ソースコード

diff #

use std::collections::{BTreeSet, HashMap, HashSet};

fn main() {
    proconio::input! {
        n: usize,
        a: i64,
        b: i64,
        x: [i64; n],
    }
    let 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[first..last]
                .iter()
                .copied()
                .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[first..last]
                .iter()
                .copied()
                .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]);
    }
}
0