結果

問題 No.3 ビットすごろく
ユーザー tabataba
提出日時 2024-07-30 11:45:55
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 710 bytes
コンパイル時間 11,402 ms
コンパイル使用メモリ 402,316 KB
実行使用メモリ 14,008 KB
最終ジャッジ日時 2024-07-30 11:46:28
合計ジャッジ時間 28,201 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,988 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 700 ms
6,944 KB
testcase_04 AC 4 ms
6,944 KB
testcase_05 AC 3,376 ms
6,940 KB
testcase_06 AC 857 ms
6,944 KB
testcase_07 AC 14 ms
6,940 KB
testcase_08 AC 87 ms
6,940 KB
testcase_09 AC 220 ms
6,944 KB
testcase_10 AC 290 ms
6,940 KB
testcase_11 AC 188 ms
6,940 KB
testcase_12 AC 3,281 ms
6,940 KB
testcase_13 AC 423 ms
6,944 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused import: `HashMap`
 --> src/main.rs:1:24
  |
1 | use std::collections::{HashMap, HashSet};
  |                        ^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `proconio::marker::Chars`
 --> src/main.rs:3:5
  |
3 | use proconio::marker::Chars;
  |     ^^^^^^^^^^^^^^^^^^^^^^^

ソースコード

diff #

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

use proconio::marker::Chars;

fn main() {
    proconio::input! {
        n: i64,
    }
    let mut hs = HashSet::new();
    hs.insert(1);
    for i in 1..n * 2 {
        if hs.contains(&n) {
            println!("{i}");
            return;
        }
        let mut new_hs = HashSet::new();
        hs.into_iter().for_each(|v| {
            let m = v.count_ones() as i64;
            if v - m >= 1 {
                new_hs.insert(v - m);
            }
            if v + m <= n {
                new_hs.insert(v + m);
            }
        });
        hs = new_hs;
    }
    println!("-1");
}

#[cfg(test)]
mod test {
    use super::*;
    #[test]
    fn test() {}
}
0