結果

問題 No.2768 Password Crack
ユーザー あさくちあさくち
提出日時 2024-06-01 15:01:16
言語 Rust
(1.77.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 1,002 bytes
コンパイル時間 20,833 ms
コンパイル使用メモリ 379,808 KB
実行使用メモリ 25,232 KB
平均クエリ数 1785.17
最終ジャッジ日時 2024-06-01 15:01:42
合計ジャッジ時間 18,490 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
24,848 KB
testcase_01 AC 23 ms
25,232 KB
testcase_02 AC 94 ms
24,592 KB
testcase_03 AC 95 ms
25,232 KB
testcase_04 AC 93 ms
24,976 KB
testcase_05 AC 32 ms
25,232 KB
testcase_06 AC 93 ms
24,848 KB
testcase_07 AC 95 ms
25,088 KB
testcase_08 AC 42 ms
24,592 KB
testcase_09 AC 92 ms
24,592 KB
testcase_10 AC 94 ms
24,592 KB
testcase_11 AC 94 ms
25,220 KB
testcase_12 AC 93 ms
25,232 KB
testcase_13 AC 96 ms
24,976 KB
testcase_14 AC 92 ms
24,592 KB
testcase_15 AC 94 ms
24,848 KB
testcase_16 AC 95 ms
25,232 KB
testcase_17 AC 95 ms
24,916 KB
testcase_18 AC 96 ms
25,232 KB
testcase_19 AC 60 ms
24,592 KB
testcase_20 AC 58 ms
24,848 KB
testcase_21 AC 94 ms
25,232 KB
testcase_22 AC 77 ms
24,592 KB
testcase_23 AC 36 ms
24,976 KB
testcase_24 AC 52 ms
25,232 KB
testcase_25 AC 90 ms
24,976 KB
testcase_26 AC 54 ms
24,848 KB
testcase_27 AC 77 ms
24,848 KB
testcase_28 AC 36 ms
25,232 KB
testcase_29 AC 43 ms
25,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::{input, source::line::LineSource};
use std::{
    collections::HashMap,
    io::{stdin, BufReader},
};

fn main() {
    let stdin = stdin();
    let mut source = LineSource::new(BufReader::new(stdin.lock()));

    input! {
        from &mut source,
        n: usize,
    }

    let mut base: Vec<_> = (0..n).map(|_| 'a').collect();

    for i in 0..n {
        let mut score = HashMap::new();

        // z なし
        for c in 'a'..'z' {
            let mut t = base.clone();
            t[i] = c;

            let text: String = t.iter().collect();

            println!("? {}", text);

            input! {
                from &mut source,
                hit: usize,
            }

            score.insert(hit, c);
        }

        if score.len() == 1 {
            base[i] = 'z';
        } else {
            let max_c = score.iter().max().unwrap();
            base[i] = *max_c.1;
        }
    }

    let text: String = base.iter().collect();

    println!("! {}", text);
}
0