結果
問題 | No.2252 Find Zero |
ユーザー | Daylight |
提出日時 | 2023-03-25 11:25:17 |
言語 | Rust (1.77.0) |
結果 |
AC
|
実行時間 | 73 ms / 2,000 ms |
コード長 | 2,218 bytes |
コンパイル時間 | 1,127 ms |
コンパイル使用メモリ | 178,020 KB |
実行使用メモリ | 24,516 KB |
平均クエリ数 | 78.17 |
最終ジャッジ日時 | 2023-10-18 22:45:12 |
合計ジャッジ時間 | 2,930 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 63 ms
24,516 KB |
testcase_01 | AC | 73 ms
24,516 KB |
testcase_02 | AC | 53 ms
24,516 KB |
testcase_03 | AC | 63 ms
24,516 KB |
testcase_04 | AC | 54 ms
24,516 KB |
testcase_05 | AC | 51 ms
24,516 KB |
testcase_06 | AC | 53 ms
24,516 KB |
testcase_07 | AC | 51 ms
24,516 KB |
testcase_08 | AC | 60 ms
24,516 KB |
testcase_09 | AC | 64 ms
24,516 KB |
testcase_10 | AC | 52 ms
24,516 KB |
testcase_11 | AC | 52 ms
24,516 KB |
testcase_12 | AC | 51 ms
24,516 KB |
testcase_13 | AC | 51 ms
24,516 KB |
testcase_14 | AC | 52 ms
24,516 KB |
testcase_15 | AC | 51 ms
24,516 KB |
testcase_16 | AC | 53 ms
24,516 KB |
testcase_17 | AC | 52 ms
24,516 KB |
ソースコード
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 } } }