QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#779536 | #9794. ICPC Shenyang in NEU, the Tenth Consecutive Year | Lord-scheme | RE | 0ms | 2096kb | Rust | 1.9kb | 2024-11-24 19:41:17 | 2024-11-24 19:41:20 |
Judging History
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);
let ans = buf.trim().parse::<i64>().unwrap();
if ans != 0 {
break;
}
cur += 1;
}
println!("! {cur}");
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 2096kb
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...