結果

問題 No.1170 Never Want to Walk
ユーザー tabataba
提出日時 2024-08-06 10:20:14
言語 Rust
(1.77.0)
結果
AC  
実行時間 295 ms / 2,000 ms
コード長 1,788 bytes
コンパイル時間 15,421 ms
コンパイル使用メモリ 381,760 KB
実行使用メモリ 14,624 KB
最終ジャッジ日時 2024-08-06 10:20:36
合計ジャッジ時間 19,275 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 0 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 3 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 3 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 3 ms
6,940 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 4 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 283 ms
12,496 KB
testcase_28 AC 257 ms
11,924 KB
testcase_29 AC 275 ms
12,352 KB
testcase_30 AC 295 ms
12,416 KB
testcase_31 AC 276 ms
12,576 KB
testcase_32 AC 250 ms
13,668 KB
testcase_33 AC 245 ms
14,624 KB
testcase_34 AC 290 ms
14,036 KB
testcase_35 AC 255 ms
14,128 KB
testcase_36 AC 252 ms
13,624 KB
testcase_37 AC 237 ms
13,760 KB
testcase_38 AC 275 ms
14,216 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused imports: `BTreeSet`, `HashMap`, `HashSet`
 --> src/main.rs:1:24
  |
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 mut x = x.into_iter().enumerate().collect::<Vec<_>>();
    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]);
    }
}
0