結果

問題 No.2768 Password Crack
ユーザー atcoder8atcoder8
提出日時 2024-05-31 22:22:29
言語 Rust
(1.77.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 1,083 bytes
コンパイル時間 13,455 ms
コンパイル使用メモリ 390,872 KB
実行使用メモリ 25,488 KB
平均クエリ数 1785.17
最終ジャッジ日時 2024-05-31 22:22:58
合計ジャッジ時間 17,917 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
24,976 KB
testcase_01 AC 25 ms
25,232 KB
testcase_02 AC 98 ms
24,976 KB
testcase_03 AC 97 ms
25,488 KB
testcase_04 AC 94 ms
24,848 KB
testcase_05 AC 33 ms
25,092 KB
testcase_06 AC 95 ms
24,976 KB
testcase_07 AC 96 ms
24,592 KB
testcase_08 AC 44 ms
25,232 KB
testcase_09 AC 95 ms
25,232 KB
testcase_10 AC 95 ms
25,232 KB
testcase_11 AC 93 ms
24,464 KB
testcase_12 AC 94 ms
25,232 KB
testcase_13 AC 94 ms
24,848 KB
testcase_14 AC 93 ms
25,232 KB
testcase_15 AC 94 ms
25,232 KB
testcase_16 AC 96 ms
24,464 KB
testcase_17 AC 97 ms
25,232 KB
testcase_18 AC 95 ms
24,976 KB
testcase_19 AC 61 ms
25,232 KB
testcase_20 AC 58 ms
25,232 KB
testcase_21 AC 95 ms
24,592 KB
testcase_22 AC 78 ms
24,848 KB
testcase_23 AC 37 ms
24,788 KB
testcase_24 AC 54 ms
25,476 KB
testcase_25 AC 92 ms
24,976 KB
testcase_26 AC 56 ms
25,232 KB
testcase_27 AC 78 ms
25,232 KB
testcase_28 AC 39 ms
24,592 KB
testcase_29 AC 44 ms
24,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Write;

fn main() {
    let n = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse::<usize>().unwrap()
    };

    let mut t = vec!['a'; n];
    for i in 0..n {
        let scores = ('a'..'z')
            .map(|c| {
                t[i] = c;
                let ask = t.iter().collect::<String>();
                println!("? {}", ask);
                std::io::stdout().flush().unwrap();
                let score = {
                    let mut line = String::new();
                    std::io::stdin().read_line(&mut line).unwrap();
                    line.trim().parse::<usize>().unwrap()
                };

                score
            })
            .collect::<Vec<usize>>();

        if scores.iter().all(|&score| score == scores[0]) {
            t[i] = 'z';
        } else {
            let pos = (0..25).max_by_key(|&pos| scores[pos]).unwrap();
            t[i] = (b'a' + pos as u8) as char
        }
    }

    let ans = t.iter().collect::<String>();
    println!("! {}", ans);
}
0