結果

問題 No.246 質問と回答
ユーザー sinosino
提出日時 2020-04-17 23:14:22
言語 Rust
(1.77.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 1,358 bytes
コンパイル時間 877 ms
コンパイル使用メモリ 136,060 KB
実行使用メモリ 24,324 KB
平均クエリ数 31.53
最終ジャッジ日時 2023-09-23 20:34:28
合計ジャッジ時間 4,180 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
23,376 KB
testcase_01 AC 42 ms
24,324 KB
testcase_02 AC 41 ms
23,964 KB
testcase_03 AC 42 ms
23,556 KB
testcase_04 AC 41 ms
23,700 KB
testcase_05 AC 40 ms
24,048 KB
testcase_06 AC 41 ms
23,340 KB
testcase_07 AC 40 ms
24,060 KB
testcase_08 AC 41 ms
24,060 KB
testcase_09 AC 41 ms
24,072 KB
testcase_10 AC 41 ms
23,772 KB
testcase_11 AC 41 ms
23,676 KB
testcase_12 AC 40 ms
23,424 KB
testcase_13 AC 41 ms
23,604 KB
testcase_14 AC 41 ms
23,904 KB
testcase_15 AC 41 ms
23,556 KB
testcase_16 AC 41 ms
23,592 KB
testcase_17 AC 42 ms
23,424 KB
testcase_18 AC 41 ms
23,928 KB
testcase_19 AC 40 ms
23,652 KB
testcase_20 AC 41 ms
23,472 KB
testcase_21 AC 40 ms
24,072 KB
testcase_22 AC 40 ms
23,484 KB
testcase_23 AC 40 ms
23,328 KB
testcase_24 AC 41 ms
23,412 KB
testcase_25 AC 41 ms
23,556 KB
testcase_26 AC 41 ms
23,676 KB
testcase_27 AC 41 ms
23,664 KB
testcase_28 AC 42 ms
23,304 KB
testcase_29 AC 40 ms
23,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_end().to_owned()
}

fn main() {
    use std::io::{self, Write};
    let mut lb = 0u64;
    let mut ub = 1000000000u64;

    while ub - lb > 1 {
        let q = (lb + ub) / 2;
        println!("? {}", q);
        io::stdout().flush().unwrap();
        let react = read!(i32);
        if react == 1 {
            lb = q;
        } else {
            ub = q - 1;
        }
    }

    println!("? {}", ub);
    let react = read!(i32);
    if react == 1 {
        println!("! {}", ub);
    }
    else {
        println!("! {}", lb);
    }

}
0