結果
問題 | No.2252 Find Zero |
ユーザー |
|
提出日時 | 2023-03-25 11:25:17 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 63 ms / 2,000 ms |
コード長 | 2,218 bytes |
コンパイル時間 | 14,559 ms |
コンパイル使用メモリ | 378,080 KB |
実行使用メモリ | 25,488 KB |
平均クエリ数 | 78.17 |
最終ジャッジ日時 | 2024-09-18 18:44:58 |
合計ジャッジ時間 | 13,459 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
use scanner::*; fn main() { let mut scanner = Scanner::default(); let n = scanner.next::<usize>(); for i in 0..n / 2 { println!("? {} {}", i * 2, i * 2 + 1); let response = scanner.next::<usize>(); if response == i * 2 { println!("! {}", i * 2 + 1); return; } else if response == i * 2 + 1 { println!("! {}", i * 2); return; } } println!("! {}", n - 1); } #[macro_export] macro_rules! min { ($a:expr $(,)*) => {{ $a }}; ($a:expr, $b:expr $(,)*) => {{ cmp::min($a, $b) }}; ($a:expr, $($rest:expr),+ $(,)*)=>{{ cmp::min($a,min!($($rest),+)) }} } #[macro_export] macro_rules! max { ($a:expr $(,)*) => {{ $a }}; ($a:expr, $b:expr $(,)*) => {{ cmp::min($a, $b) }}; ($a:expr, $($rest:expr),+ $(,)*)=>{{ cmp::min($a,min!($($rest),+)) }} } #[macro_export] macro_rules! chmin{ ($base:expr, $($cmps:expr),+ $(,)*)=>{{ let cmp_min = min!($($cmps),+); if $base > cmp_min{ $base = cmp_min; true }else{ false } }} } #[macro_export] macro_rules! chmax{ ($base:expr, $($cmps:expr),+ $(,)*)=>{{ let cmp_max = max!($($cmps),+); if $base < cmp_min{ $base = cmp_min; true }else{ false } }} } pub mod scanner { use std::{io::stdin, str::FromStr}; #[derive(Default)] pub struct Scanner { buf: Vec<String>, } impl Scanner { pub fn next<T: FromStr>(&mut self) -> T { while self.buf.is_empty() { let mut input = String::new(); stdin().read_line(&mut input).ok(); self.buf = input.trim().split_whitespace().map(String::from).collect(); } let token = self.buf.pop().unwrap(); token.parse().ok().expect("Parse Error") } pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(self.next()); } v } } }