QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#779529#9794. ICPC Shenyang in NEU, the Tenth Consecutive YearLord-schemeRE 1ms2272kbRust1.9kb2024-11-24 19:38:102024-11-24 19:38:13

Judging History

你现在查看的是最新测评结果

  • [2024-11-24 19:38:13]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:2272kb
  • [2024-11-24 19:38:10]
  • 提交

answer

use std::io;
use std::io::BufRead;
use std::str;

pub struct Scanner<R> {
    reader: R,
    buffer: Vec<String>,
}

impl<R: io::BufRead> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buffer: vec![],
        }
    }

    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }

    pub fn next<T: str::FromStr>(&mut self) -> Option<T> {
        let res = self.buffer.pop();
        match res {
            Some(token) => {
                if let Ok(value) = token.parse() {
                    return Some(value);
                }
                self.buffer.push(token);
            }
            None => {
                let mut input = String::new();
                self.reader.read_line(&mut input).expect("Failed read");
                self.buffer = input.split_whitespace().rev().map(String::from).collect();
            }
        }
        None
    }
}

#[allow(dead_code)]
#[allow(non_snake_case)]
fn main() {
    let mut handle = io::stdin().lock();
    let mut buf = String::new();
    handle.read_line(&mut buf).unwrap();
    let T = buf.trim().parse::<usize>().unwrap();
    for _ in 0..T {
        let mut cur = 1923 as usize;
        loop {
            println!("? {cur}");
            buf.clear();
            handle.read_line(&mut buf).unwrap();
            let ans = buf.trim().parse::<i64>().unwrap();
            if ans != 0 {
                break;
            }
            cur += 1;
        }
        println!("! {cur}");
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 2272kb

input:

1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1

output:

? 1923
? 1924
? 1925
? 1926
? 1927
? 1928
? 1929
? 1930
? 1931
? 1932
? 1933
? 1934
? 1935
? 1936
? 1937
? 1938
? 1939
? 1940
? 1941
? 1942
? 1943
? 1944
? 1945
? 1946
? 1947
? 1948
? 1949
? 1950
? 1951
? 1952
? 1953
? 1954
? 1955
? 1956
? 1957
? 1958
? 1959
? 1960
? 1961
? 1962
? 1963
? 1964
? 1965...

result:

ok correct! (1 test case)

Test #2:

score: -100
Runtime Error

input:

100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

output:

? 1923
? 1924
? 1925
? 1926
? 1927
? 1928
? 1929
? 1930
? 1931
? 1932
? 1933
? 1934
? 1935
? 1936
? 1937
? 1938
? 1939
? 1940
? 1941
? 1942
? 1943
? 1944
! 1944
? 1923
? 1924
? 1925
? 1926
? 1927
? 1928
? 1929
? 1930
? 1931
? 1932
? 1933
? 1934
? 1935
? 1936
? 1937
? 1938
? 1939
? 1940
? 1941
? 1942...

result: