結果

問題 No.305 鍵(2)
ユーザー tonyu0tonyu0
提出日時 2020-04-29 18:06:39
言語 Rust
(1.77.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 830 bytes
コンパイル時間 4,059 ms
コンパイル使用メモリ 145,816 KB
実行使用メモリ 24,372 KB
平均クエリ数 50.62
最終ジャッジ日時 2023-09-24 02:36:35
合計ジャッジ時間 2,221 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
23,328 KB
testcase_01 AC 24 ms
23,352 KB
testcase_02 AC 24 ms
23,412 KB
testcase_03 AC 24 ms
23,364 KB
testcase_04 AC 23 ms
24,372 KB
testcase_05 AC 21 ms
23,772 KB
testcase_06 AC 26 ms
24,348 KB
testcase_07 AC 24 ms
24,168 KB
testcase_08 AC 24 ms
23,508 KB
testcase_09 AC 24 ms
24,168 KB
testcase_10 AC 24 ms
23,640 KB
testcase_11 AC 22 ms
23,400 KB
testcase_12 AC 24 ms
23,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn input(a: &[usize]) -> (usize, String) {
    for i in 0..10 {
        print!("{}", a[i]);
    }
    println!("",);
    let mut s: String = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n = itr.next().unwrap().parse().unwrap();
    let s = itr.next().unwrap().to_string();
    (n, s)
}

fn main() {
    let mut ans = vec![9; 10];
    let mut target = 0;

    let res = input(&ans);
    if res.1 == "unlocked" {
        return;
    }
    let mut same = res.0;

    loop {
        ans[target] -= 1;
        let (n, s) = input(&ans);
        if s == "unlocked" {
            break;
        }
        if n > same {
            same = n;
            target += 1;
        } else if n < same {
            ans[target] += 1;
            target += 1;
        }
    }
}
0