結果
| 問題 |
No.2252 Find Zero
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-03-25 11:23:53 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,214 bytes |
| コンパイル時間 | 16,733 ms |
| コンパイル使用メモリ | 378,196 KB |
| 実行使用メモリ | 25,616 KB |
| 平均クエリ数 | 78.17 |
| 最終ジャッジ日時 | 2024-09-18 18:44:06 |
| 合計ジャッジ時間 | 15,229 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 WA * 4 |
ソースコード
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);
}
#[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
}
}
}