QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#541747#8939. Permutationucup-team296#AC ✓138ms32024kbRust15.4kb2024-08-31 20:49:572024-08-31 20:49:57

Judging History

This is the latest submission verdict.

  • [2024-08-31 20:49:57]
  • Judged
  • Verdict: AC
  • Time: 138ms
  • Memory: 32024kb
  • [2024-08-31 20:49:57]
  • Submitted

answer

// 
pub mod solution {
//{"name":"h","group":"Manual","url":"","interactive":false,"timeLimit":2000,"tests":[{"input":"","output":""}],"testType":"single","input":{"type":"stdin","fileName":null,"pattern":null},"output":{"type":"stdout","fileName":null,"pattern":null},"languages":{"java":{"taskClass":"h"}}}

use std::io::Write;

#[allow(unused)]
use crate::dbg;
use crate::algo_lib::io::input::Input;
use crate::algo_lib::io::output::Output;

fn solve(input: &mut Input, out: &mut Output, _test_case: usize) {
    const MAX: usize = 1_000_010;
    let mut splits = vec![0, 0, 0];
    let mut sum_len = vec![0, 0, 2];
    let mut queries = vec![0, 0, 1];
    for n in 3..=MAX {
        let mut split = splits[n - 1].max(1);
        while split + 1 < n && sum_len[split + 1] + n <= 3 * n {
            let cur_queries = (1 + queries[split]).max(2 + queries[n - split]);
            let next_queries = (1 + queries[split + 1]).max(2 + queries[n - split - 1]);
            if next_queries > cur_queries {
                break;
            }
            split += 1;
        }
        splits.push(split);
        let left = n - split;
        let mut next_sum_len = sum_len[split] + n;
        next_sum_len = next_sum_len.max(n + split + sum_len[left]);
        sum_len.push(next_sum_len);
        let mut next_queries = 1 + queries[split];
        if queries[split] == 0 {
            next_queries = 2;
        }
        next_queries = next_queries.max(2 + queries[left]);
        queries.push(next_queries);
        let max_allowed_queries = ((n as f64).log2() * 1.5).ceil() as usize;
        assert!(next_sum_len <= 3 * n);
        assert!(next_queries <= max_allowed_queries);
    }
    let tc = input.usize();
    for _ in 0..tc {
        let n = input.usize();
        let mut from = 1;
        let mut to = n;
        let mut second_max = None;
        while from < to {
            // dbg!(from, to);
            if second_max.is_none() {
                out.println(format!("? {} {}", from, to));
                out.flush();
                second_max = Some(input.usize());
            }
            let n = to - from + 1;
            if n == 2 {
                if second_max.unwrap() == from {
                    from += 1;
                } else {
                    to -= 1;
                }
            } else {
                let split = splits[n];
                if from + split > second_max.unwrap() {
                    let mid = from + split - 1;
                    out.println(format!("? {} {}", from, mid));
                    out.flush();
                    let pos = input.usize();
                    if pos == second_max.unwrap() {
                        to = mid;
                    } else {
                        from = mid + 1;
                        second_max = None;
                    }
                } else {
                    let mid = to - split + 1;
                    out.println(format!("? {} {}", mid, to));
                    out.flush();
                    let pos = input.usize();
                    if pos == second_max.unwrap() {
                        from = mid;
                    } else {
                        to = mid - 1;
                        second_max = None;
                    }
                }
            }
        }
        out.println(format!("! {}", from));
        out.flush();
    }
}

pub(crate) fn run(mut input: Input, mut output: Output) -> bool {
    solve(&mut input, &mut output, 1);
    output.flush();
    true
}

}
pub mod algo_lib {
pub mod io {
pub mod input {
use std::fmt::Debug;
use std::io::Read;
use std::marker::PhantomData;
use std::path::Path;
use std::str::FromStr;

pub struct Input {
    input: Box<dyn Read>,
    buf: Vec<u8>,
    at: usize,
    buf_read: usize,
}

macro_rules! read_integer_fun {
    ($t:ident) => {
        #[allow(unused)]
        pub fn $t(&mut self) -> $t {
            self.read_integer()
        }
    };
}

impl Input {
    const DEFAULT_BUF_SIZE: usize = 4096;

    ///
    /// Using with stdin:
    /// ```no_run
    /// use algo_lib::io::input::Input;
    /// let stdin = std::io::stdin();
    /// let input = Input::new(Box::new(stdin));
    /// ```
    ///
    /// For read files use ``new_file`` instead.
    ///
    ///
    pub fn new(input: Box<dyn Read>) -> Self {
        Self {
            input,
            buf: vec![0; Self::DEFAULT_BUF_SIZE],
            at: 0,
            buf_read: 0,
        }
    }

    pub fn new_stdin() -> Self {
        let stdin = std::io::stdin();
        Self::new(Box::new(stdin))
    }

    pub fn new_file<P: AsRef<Path>>(path: P) -> Self {
        let file = std::fs::File::open(&path)
            .unwrap_or_else(|_| panic!("Can't open file: {:?}", path.as_ref().as_os_str()));
        Self::new(Box::new(file))
    }

    pub fn new_with_size(input: Box<dyn Read>, buf_size: usize) -> Self {
        Self {
            input,
            buf: vec![0; buf_size],
            at: 0,
            buf_read: 0,
        }
    }

    pub fn new_file_with_size<P: AsRef<Path>>(path: P, buf_size: usize) -> Self {
        let file = std::fs::File::open(&path)
            .unwrap_or_else(|_| panic!("Can't open file: {:?}", path.as_ref().as_os_str()));
        Self::new_with_size(Box::new(file), buf_size)
    }

    pub fn get(&mut self) -> Option<u8> {
        if self.refill_buffer() {
            let res = self.buf[self.at];
            self.at += 1;
            Some(res)
        } else {
            None
        }
    }

    pub fn peek(&mut self) -> Option<u8> {
        if self.refill_buffer() {
            Some(self.buf[self.at])
        } else {
            None
        }
    }

    pub fn skip_whitespace(&mut self) {
        while let Some(b) = self.peek() {
            if !char::from(b).is_whitespace() {
                return;
            }
            self.get();
        }
    }

    pub fn next_token(&mut self) -> Option<Vec<u8>> {
        self.skip_whitespace();
        let mut res = Vec::new();
        while let Some(c) = self.get() {
            if char::from(c).is_whitespace() {
                break;
            }
            res.push(c);
        }
        if res.is_empty() {
            None
        } else {
            Some(res)
        }
    }

    //noinspection RsSelfConvention
    pub fn is_exhausted(&mut self) -> bool {
        self.peek().is_none()
    }

    pub fn has_more_elements(&mut self) -> bool {
        !self.is_exhausted()
    }

    pub fn read<T: Readable>(&mut self) -> T {
        T::read(self)
    }

    pub fn vec<T: Readable>(&mut self, size: usize) -> Vec<T> {
        let mut res = Vec::with_capacity(size);
        for _ in 0usize..size {
            res.push(self.read());
        }
        res
    }

    pub fn string_vec(&mut self, size: usize) -> Vec<Vec<u8>> {
        let mut res = Vec::with_capacity(size);
        for _ in 0usize..size {
            res.push(self.string());
        }
        res
    }

    pub fn read_line(&mut self) -> String {
        let mut res = String::new();
        while let Some(c) = self.get() {
            if c == b'\n' {
                break;
            }
            if c == b'\r' {
                if self.peek() == Some(b'\n') {
                    self.get();
                }
                break;
            }
            res.push(c.into());
        }
        res
    }

    #[allow(clippy::should_implement_trait)]
    pub fn into_iter<T: Readable>(self) -> InputIterator<T> {
        InputIterator {
            input: self,
            phantom: Default::default(),
        }
    }

    fn read_integer<T: FromStr + Debug>(&mut self) -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let res = self.read_string();
        res.parse::<T>().unwrap()
    }

    fn read_string(&mut self) -> String {
        match self.next_token() {
            None => {
                panic!("Input exhausted");
            }
            Some(res) => unsafe { String::from_utf8_unchecked(res) },
        }
    }

    pub fn string_as_string(&mut self) -> String {
        self.read_string()
    }

    pub fn string(&mut self) -> Vec<u8> {
        self.read_string().into_bytes()
    }

    fn read_char(&mut self) -> char {
        self.skip_whitespace();
        self.get().unwrap().into()
    }

    fn read_float(&mut self) -> f64 {
        self.read_string().parse().unwrap()
    }

    pub fn f64(&mut self) -> f64 {
        self.read_float()
    }

    fn refill_buffer(&mut self) -> bool {
        if self.at == self.buf_read {
            self.at = 0;
            self.buf_read = self.input.read(&mut self.buf).unwrap();
            self.buf_read != 0
        } else {
            true
        }
    }

    read_integer_fun!(i32);
    read_integer_fun!(i64);
    read_integer_fun!(i128);
    read_integer_fun!(u32);
    read_integer_fun!(u64);
    read_integer_fun!(usize);
}

pub trait Readable {
    fn read(input: &mut Input) -> Self;
}

impl Readable for String {
    fn read(input: &mut Input) -> Self {
        input.read_string()
    }
}

impl Readable for char {
    fn read(input: &mut Input) -> Self {
        input.read_char()
    }
}

impl Readable for f64 {
    fn read(input: &mut Input) -> Self {
        input.read_string().parse().unwrap()
    }
}

impl Readable for f32 {
    fn read(input: &mut Input) -> Self {
        input.read_string().parse().unwrap()
    }
}

impl<T: Readable> Readable for Vec<T> {
    fn read(input: &mut Input) -> Self {
        let size = input.read();
        input.vec(size)
    }
}

pub struct InputIterator<T: Readable> {
    input: Input,
    phantom: PhantomData<T>,
}

impl<T: Readable> Iterator for InputIterator<T> {
    type Item = T;

    fn next(&mut self) -> Option<Self::Item> {
        self.input.skip_whitespace();
        self.input.peek().map(|_| self.input.read())
    }
}

macro_rules! read_integer {
    ($t:ident) => {
        impl Readable for $t {
            fn read(input: &mut Input) -> Self {
                input.read_integer()
            }
        }
    };
}

read_integer!(i8);
read_integer!(i16);
read_integer!(i32);
read_integer!(i64);
read_integer!(i128);
read_integer!(isize);
read_integer!(u8);
read_integer!(u16);
read_integer!(u32);
read_integer!(u64);
read_integer!(u128);
read_integer!(usize);
}
pub mod output {
use std::io::Write;

pub struct Output {
    output: Box<dyn Write>,
    buf: Vec<u8>,
    at: usize,
    auto_flush: bool,
}

impl Output {
    const DEFAULT_BUF_SIZE: usize = 4096;

    pub fn new(output: Box<dyn Write>) -> Self {
        Self {
            output,
            buf: vec![0; Self::DEFAULT_BUF_SIZE],
            at: 0,
            auto_flush: false,
        }
    }

    pub fn new_stdout() -> Self {
        let stdout = std::io::stdout();
        Self::new(Box::new(stdout))
    }

    pub fn new_file(path: impl AsRef<std::path::Path>) -> Self {
        let file = std::fs::File::create(path).unwrap();
        Self::new(Box::new(file))
    }

    pub fn new_with_auto_flush(output: Box<dyn Write>) -> Self {
        Self {
            output,
            buf: vec![0; Self::DEFAULT_BUF_SIZE],
            at: 0,
            auto_flush: true,
        }
    }

    pub fn flush(&mut self) {
        if self.at != 0 {
            self.output.write_all(&self.buf[..self.at]).unwrap();
            self.at = 0;
            self.output.flush().expect("Couldn't flush output");
        }
    }

    pub fn print<T: Writable>(&mut self, s: T) {
        s.write(self);
    }

    pub fn println<T: Writable>(&mut self, s: T) {
        s.write(self);
        self.put(b'\n');
    }

    pub fn put(&mut self, b: u8) {
        self.buf[self.at] = b;
        self.at += 1;
        if self.at == self.buf.len() {
            self.flush();
        }
    }

    pub fn maybe_flush(&mut self) {
        if self.auto_flush {
            self.flush();
        }
    }

    pub fn print_per_line<T: Writable>(&mut self, arg: &[T]) {
        for i in arg {
            i.write(self);
            self.put(b'\n');
        }
    }

    pub fn print_iter<T: Writable, I: Iterator<Item = T>>(&mut self, iter: I) {
        let mut first = true;
        for e in iter {
            if first {
                first = false;
            } else {
                self.put(b' ');
            }
            e.write(self);
        }
    }

    pub fn print_iter_ref<'a, T: 'a + Writable, I: Iterator<Item = &'a T>>(&mut self, iter: I) {
        let mut first = true;
        for e in iter {
            if first {
                first = false;
            } else {
                self.put(b' ');
            }
            e.write(self);
        }
    }
}

impl Write for Output {
    fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
        let mut start = 0usize;
        let mut rem = buf.len();
        while rem > 0 {
            let len = (self.buf.len() - self.at).min(rem);
            self.buf[self.at..self.at + len].copy_from_slice(&buf[start..start + len]);
            self.at += len;
            if self.at == self.buf.len() {
                self.flush();
            }
            start += len;
            rem -= len;
        }
        if self.auto_flush {
            self.flush();
        }
        Ok(buf.len())
    }

    fn flush(&mut self) -> std::io::Result<()> {
        self.flush();
        Ok(())
    }
}

pub trait Writable {
    fn write(&self, output: &mut Output);
}

impl Writable for &str {
    fn write(&self, output: &mut Output) {
        output.write_all(self.as_bytes()).unwrap();
    }
}

impl Writable for String {
    fn write(&self, output: &mut Output) {
        output.write_all(self.as_bytes()).unwrap();
    }
}

impl Writable for char {
    fn write(&self, output: &mut Output) {
        output.put(*self as u8);
    }
}

impl<T: Writable> Writable for [T] {
    fn write(&self, output: &mut Output) {
        output.print_iter_ref(self.iter());
    }
}

impl<T: Writable> Writable for Vec<T> {
    fn write(&self, output: &mut Output) {
        self[..].write(output);
    }
}

macro_rules! write_to_string {
    ($t:ident) => {
        impl Writable for $t {
            fn write(&self, output: &mut Output) {
                self.to_string().write(output);
            }
        }
    };
}

write_to_string!(u8);
write_to_string!(u16);
write_to_string!(u32);
write_to_string!(u64);
write_to_string!(u128);
write_to_string!(usize);
write_to_string!(i8);
write_to_string!(i16);
write_to_string!(i32);
write_to_string!(i64);
write_to_string!(i128);
write_to_string!(isize);
write_to_string!(f32);
write_to_string!(f64);

impl<T: Writable, U: Writable> Writable for (T, U) {
    fn write(&self, output: &mut Output) {
        self.0.write(output);
        output.put(b' ');
        self.1.write(output);
    }
}

impl<T: Writable, U: Writable, V: Writable> Writable for (T, U, V) {
    fn write(&self, output: &mut Output) {
        self.0.write(output);
        output.put(b' ');
        self.1.write(output);
        output.put(b' ');
        self.2.write(output);
    }
}
}
}
pub mod misc {
pub mod dbg_macro {
#[macro_export]
#[allow(unused_macros)]
macro_rules! dbg {
    ($first_val:expr, $($val:expr),+ $(,)?) => {
        eprint!("[{}:{}] {} = {:?}",
                    file!(), line!(), stringify!($first_val), &$first_val);
        ($(eprint!(", {} = {:?}", stringify!($val), &$val)),+,);
        eprintln!();
    };
    ($first_val:expr) => {
        eprintln!("[{}:{}] {} = {:?}",
                    file!(), line!(), stringify!($first_val), &$first_val)
    };
}
}
}
}
fn main() {
    let input = algo_lib::io::input::Input::new_stdin();
    let mut output = algo_lib::io::output::Output::new_stdout();
    crate::solution::run(input, output);
}

详细

Test #1:

score: 100
Accepted
time: 21ms
memory: 28592kb

input:

3
5
3
2
5
6
6
6
5
3
4
3
2

output:

? 1 5
? 1 3
? 4 5
! 4
? 1 6
? 2 6
? 4 6
? 2 3
! 2
? 1 4
? 1 3
! 4

result:

ok Correct (3 test cases)

Test #2:

score: 0
Accepted
time: 81ms
memory: 27340kb

input:

10000
10
2
2
2
3
5
10
10
10
10
8
7
10
5
5
1
6
6
10
4
4
4
4
4
10
10
3
2
10
3
3
3
3
2
10
1
1
5
6
7
10
1
1
3
8
8
10
2
4
9
10
3
3
3
1
5
10
4
7
9
10
8
8
7
1
2
10
4
1
9
10
7
7
7
8
4
10
5
1
10
10
8
6
9
10
2
2
1
7
7
10
6
4
10
10
1
1
3
8
8
10
7
7
5
1
2
10
7
7
4
1
2
10
3
4
10
10
4
4
4
4
3
10
8
8
7
2
2
10
8
8
...

output:

? 1 10
? 1 8
? 1 5
? 1 3
? 4 5
! 4
? 1 10
? 3 10
? 6 10
? 8 10
? 6 7
! 6
? 1 10
? 1 8
? 1 5
? 6 8
? 6 7
! 7
? 1 10
? 1 8
? 1 5
? 3 5
? 3 4
! 3
? 1 10
? 3 10
? 1 2
! 1
? 1 10
? 1 8
? 1 5
? 1 3
? 2 3
! 1
? 1 10
? 1 8
? 1 5
? 6 8
? 6 7
! 8
? 1 10
? 1 8
? 1 5
? 6 8
? 7 8
! 7
? 1 10
? 1 8
? 9 10
! 10
? 1...

result:

ok Correct (10000 test cases)

Test #3:

score: 0
Accepted
time: 67ms
memory: 27384kb

input:

10000
3
1
2
11
5
5
3
8
7
2
2
19
3
3
4
13
12
9
7
5
5
5
4
3
3
3
19
6
6
6
7
1
2
2
2
15
11
11
11
11
12
8
14
1
1
1
1
3
5
16
4
4
4
1
8
7
3
3
2
19
13
13
6
5
5
4
2
2
4
1
3
7
2
2
2
2
3
2
2
17
1
1
1
1
2
4
14
9
9
9
9
9
8
20
9
9
9
6
13
13
6
4
2
18
7
7
7
7
7
6
8
8
8
6
5
8
6
6
6
5
16
10
10
10
10
10
10
6
1
1
3
5
1...

output:

? 1 3
? 1 2
! 3
? 1 11
? 1 8
? 1 5
? 6 8
? 7 8
! 6
? 1 2
! 1
? 1 19
? 1 13
? 1 8
? 9 13
? 11 13
? 9 10
! 10
? 1 7
? 1 5
? 3 5
? 4 5
! 3
? 1 3
? 2 3
! 2
? 1 19
? 1 13
? 1 8
? 4 8
? 1 3
? 1 2
! 3
? 1 2
! 1
? 1 15
? 1 12
? 5 12
? 8 12
? 10 12
? 8 9
! 9
? 1 14
? 1 10
? 1 8
? 1 5
? 1 3
? 4 5
! 4
? 1 16
?...

result:

ok Correct (10000 test cases)

Test #4:

score: 0
Accepted
time: 88ms
memory: 25892kb

input:

10000
47
23
23
31
11
9
2
1
5
14
8
8
2
9
25
6
6
13
18
18
17
15
7
4
4
4
3
9
2
2
2
2
2
27
27
27
27
27
24
21
20
21
7
7
7
7
6
5
43
41
21
7
7
8
3
3
22
6
14
20
20
19
21
34
29
29
25
17
17
18
14
42
20
20
20
20
20
20
19
17
47
21
21
21
21
21
21
19
17
41
25
30
33
33
34
36
36
19
17
17
16
7
9
10
21
14
14
14
14
14...

output:

? 1 47
? 1 34
? 14 34
? 1 13
? 6 13
? 1 5
? 1 3
? 4 5
! 4
? 1 14
? 1 10
? 1 8
? 9 10
! 10
? 1 25
? 1 19
? 1 13
? 14 19
? 14 18
? 16 18
? 14 15
! 14
? 1 7
? 1 5
? 3 5
? 3 4
! 5
? 1 9
? 1 8
? 1 5
? 1 3
? 1 2
! 1
? 1 27
? 7 27
? 15 27
? 20 27
? 23 27
? 20 22
? 20 21
! 22
? 1 21
? 1 13
? 1 8
? 4 8
? 6 8...

result:

ok Correct (10000 test cases)

Test #5:

score: 0
Accepted
time: 90ms
memory: 29120kb

input:

10000
100
47
61
93
96
71
71
71
71
71
9
2
2
2
2
1
53
46
35
6
6
6
6
6
6
33
3
16
31
31
31
29
32
82
60
29
4
8
23
23
24
26
88
39
8
59
59
59
59
59
59
59
71
24
29
59
59
59
60
61
61
92
52
45
88
88
88
88
85
91
91
24
11
11
11
9
5
5
5
66
51
51
51
51
45
39
39
38
40
92
43
43
50
20
20
20
20
21
17
48
1
1
1
1
1
5
7...

output:

? 1 100
? 1 66
? 67 100
? 80 100
? 67 79
? 67 74
? 67 71
? 69 71
? 70 71
! 70
? 1 9
? 1 8
? 1 5
? 1 3
? 1 2
! 3
? 1 53
? 20 53
? 1 19
? 1 13
? 1 8
? 4 8
? 4 6
? 5 6
! 5
? 1 33
? 1 21
? 22 33
? 26 33
? 29 33
? 29 31
? 32 33
! 33
? 1 82
? 28 82
? 1 27
? 1 21
? 22 27
? 22 26
? 22 24
? 25 26
! 25
? 1 88...

result:

ok Correct (10000 test cases)

Test #6:

score: 0
Accepted
time: 89ms
memory: 27904kb

input:

10000
50
10
10
10
10
6
2
3
5
50
11
11
9
31
32
23
23
22
50
44
44
40
20
20
21
23
22
50
24
14
45
45
45
45
44
46
50
50
50
50
50
50
50
49
47
50
36
23
12
12
12
12
11
10
50
29
29
20
13
6
3
1
5
50
30
30
22
1
1
1
1
2
50
25
25
25
15
30
30
31
27
50
18
20
49
49
47
39
39
39
50
9
9
9
9
9
7
13
13
50
26
26
26
26
19...

output:

? 1 50
? 1 34
? 1 21
? 1 13
? 6 13
? 1 5
? 1 3
? 4 5
! 4
? 1 50
? 1 34
? 1 21
? 22 34
? 27 34
? 22 26
? 22 24
? 22 23
! 24
? 1 50
? 17 50
? 30 50
? 17 29
? 17 24
? 17 21
? 22 24
? 22 23
! 24
? 1 50
? 1 34
? 35 50
? 35 47
? 40 47
? 43 47
? 43 45
? 46 47
! 47
? 1 50
? 17 50
? 30 50
? 38 50
? 43 50
? 4...

result:

ok Correct (10000 test cases)

Test #7:

score: 0
Accepted
time: 138ms
memory: 28796kb

input:

10000
100
76
35
5
5
5
3
9
9
9
100
29
29
29
29
29
29
29
29
27
26
100
64
38
69
69
72
86
87
80
81
100
51
57
98
98
92
81
81
81
80
100
44
44
44
13
1
1
4
6
7
100
64
64
64
64
62
41
41
41
42
39
100
93
93
56
40
40
36
44
45
47
100
37
2
97
81
76
77
68
68
67
100
76
76
58
94
95
86
86
85
83
100
32
32
32
11
44
44
...

output:

? 1 100
? 35 100
? 1 34
? 1 21
? 1 13
? 1 8
? 9 13
? 9 11
? 9 10
! 10
? 1 100
? 1 66
? 1 46
? 1 34
? 14 34
? 22 34
? 22 29
? 25 29
? 27 29
? 25 26
! 25
? 1 100
? 1 66
? 67 100
? 67 87
? 67 79
? 80 87
? 83 87
? 80 82
? 80 81
! 82
? 1 100
? 1 66
? 67 100
? 80 100
? 88 100
? 80 87
? 80 84
? 80 82
? 80 ...

result:

ok Correct (10000 test cases)

Test #8:

score: 0
Accepted
time: 40ms
memory: 29116kb

input:

1000
1000
475
426
728
728
747
896
896
867
858
858
851
847
847
847
1000
278
278
17
446
461
598
598
618
637
637
639
640
641
643
1000
75
128
871
871
842
686
713
749
749
755
737
737
736
739
1000
239
239
45
577
577
520
458
458
458
451
459
460
466
465
1000
978
978
978
978
978
978
978
997
914
914
914
912
9...

output:

? 1 1000
? 1 667
? 668 1000
? 668 900
? 668 811
? 812 900
? 846 900
? 867 900
? 846 866
? 846 858
? 851 858
? 846 850
? 846 848
? 846 847
! 846
? 1 1000
? 1 667
? 1 445
? 446 667
? 446 589
? 590 667
? 590 644
? 590 623
? 624 644
? 632 644
? 632 639
? 640 644
? 640 642
? 643 644
! 644
? 1 1000
? 1 66...

result:

ok Correct (1000 test cases)

Test #9:

score: 0
Accepted
time: 33ms
memory: 29124kb

input:

1017
272
246
111
27
52
73
73
73
73
73
73
72
114
105
91
2
2
2
2
2
2
2
910
173
173
173
173
127
14
14
29
35
37
51
51
52
48
726
229
229
229
229
201
63
39
28
28
28
28
28
29
26
861
315
315
104
491
396
593
593
593
593
593
593
590
597
596
1984
133
133
133
406
863
869
724
704
650
650
650
650
650
650
650
649
...

output:

? 1 272
? 92 272
? 1 91
? 1 61
? 62 91
? 62 82
? 62 74
? 67 74
? 70 74
? 72 74
? 72 73
! 74
? 1 114
? 28 114
? 1 27
? 1 21
? 1 13
? 1 8
? 1 5
? 1 3
? 1 2
! 1
? 1 910
? 1 610
? 1 377
? 1 233
? 90 233
? 1 89
? 1 55
? 1 34
? 35 55
? 35 47
? 48 55
? 48 52
? 50 52
? 48 49
! 49
? 1 726
? 1 484
? 1 361
? 1...

result:

ok Correct (1017 test cases)

Test #10:

score: 0
Accepted
time: 37ms
memory: 30176kb

input:

10
100000
3893
3893
3893
3505
30673
33920
43582
43582
43582
43582
43582
43582
43470
43242
43242
43197
43289
43289
43279
43268
43268
43267
43270
43269
100000
32066
54928
88585
88585
88585
88585
89959
91599
91599
91599
91599
91474
91257
91159
91305
91325
91370
91370
91365
91355
91355
91354
91353
10000...

output:

? 1 100000
? 1 75025
? 1 46368
? 1 28657
? 28658 46368
? 28658 39603
? 39604 46368
? 39604 43784
? 41201 43784
? 42188 43784
? 42798 43784
? 43175 43784
? 43408 43784
? 43175 43407
? 43175 43318
? 43175 43263
? 43264 43318
? 43264 43297
? 43277 43297
? 43264 43276
? 43264 43271
? 43264 43268
? 43269...

result:

ok Correct (10 test cases)

Test #11:

score: 0
Accepted
time: 36ms
memory: 28600kb

input:

21
84335
47947
47947
22445
9296
1509
17079
17079
15274
18619
18476
17510
17510
17510
17496
17352
17346
17316
17316
17316
17313
17320
17321
17323
159962
128177
128177
145530
54814
54814
54814
49869
40850
38954
43214
43214
43214
43231
43550
43489
43675
43608
43695
43695
43695
43695
43695
43695
43695
4...

output:

? 1 84335
? 1 56224
? 18743 56224
? 1 18742
? 1 12494
? 12495 18742
? 14562 18742
? 14562 17145
? 17146 18742
? 17756 18742
? 17146 17755
? 17146 17522
? 17290 17522
? 17379 17522
? 17290 17378
? 17324 17378
? 17290 17323
? 17303 17323
? 17311 17323
? 17311 17318
? 17319 17323
? 17319 17321
? 17322 ...

result:

ok Correct (21 test cases)

Test #12:

score: 0
Accepted
time: 36ms
memory: 28324kb

input:

1
1000000
641602
169407
783270
783270
783270
783270
732855
805651
805651
805651
802269
797591
797591
797591
797591
797468
797004
796975
796734
796788
796850
796850
796844
796864
796864
796864
796864
796863

output:

? 1 1000000
? 1 666666
? 666667 1000000
? 666667 888889
? 666667 814814
? 714934 814814
? 714934 789958
? 789959 814814
? 789959 807669
? 796724 807669
? 800905 807669
? 796724 800904
? 796724 799307
? 796724 798320
? 796724 797710
? 797101 797710
? 796724 797100
? 796868 797100
? 796724 796867
? 79...

result:

ok Correct (1 test case)

Test #13:

score: 0
Accepted
time: 25ms
memory: 29096kb

input:

16
232936
229707
229707
229707
229707
229707
229707
229707
229707
231039
223556
224031
225790
225790
225790
225790
225611
225474
225474
225483
225438
225438
225431
225419
225418
225425
225425
8676
6498
6498
6498
6498
5867
4978
4978
4731
4684
4684
4684
4684
4684
4684
4676
4692
4692
4690
4693
221085
1...

output:

? 1 232936
? 77647 232936
? 118772 232936
? 157912 232936
? 186569 232936
? 204280 232936
? 215226 232936
? 221991 232936
? 226172 232936
? 221991 226171
? 221991 224574
? 224575 226171
? 225185 226171
? 225185 225794
? 225418 225794
? 225562 225794
? 225418 225561
? 225418 225506
? 225452 225506
? ...

result:

ok Correct (16 test cases)

Test #14:

score: 0
Accepted
time: 49ms
memory: 29904kb

input:

1994
667
666
667
222
221
78
77
23
22
8
7
3
2
374
373
374
141
140
52
51
18
17
5
4
2
488
486
488
119
118
30
29
9
8
922
921
922
312
311
79
78
24
23
7
6
2
639
637
639
213
212
69
68
17
16
4
3
353
350
353
120
119
31
30
10
9
2
71
66
71
16
15
3
2
24
21
24
7
6
2
567
562
567
190
189
46
45
12
11
4
3
116
113
11...

output:

? 1 667
? 223 667
? 1 222
? 79 222
? 1 78
? 24 78
? 1 23
? 9 23
? 1 8
? 4 8
? 1 3
? 2 3
! 1
? 1 374
? 142 374
? 1 141
? 53 141
? 1 52
? 19 52
? 1 18
? 6 18
? 1 5
? 3 5
? 1 2
! 1
? 1 488
? 120 488
? 1 119
? 31 119
? 1 30
? 10 30
? 1 9
? 2 9
! 1
? 1 922
? 313 922
? 1 312
? 80 312
? 1 79
? 25 79
? 1 24...

result:

ok Correct (1994 test cases)

Test #15:

score: 0
Accepted
time: 26ms
memory: 25884kb

input:

18
153667
153667
153666
42748
42747
14091
14090
3617
3616
1033
1032
344
343
111
110
30
29
9
8
211376
211374
211376
70459
70458
24091
24090
6380
6379
2199
2198
602
601
225
224
81
80
26
25
5
4
2
195330
195326
195330
73937
73936
27569
27568
9858
9857
3093
3092
1031
1030
343
342
110
109
31
30
10
9
2
420...

output:

? 1 153667
? 42749 153667
? 1 42748
? 14092 42748
? 1 14091
? 3618 14091
? 1 3617
? 1034 3617
? 1 1033
? 345 1033
? 1 344
? 112 344
? 1 111
? 31 111
? 1 30
? 10 30
? 1 9
? 2 9
! 1
? 1 211376
? 70460 211376
? 1 70459
? 24092 70459
? 1 24091
? 6381 24091
? 1 6380
? 2200 6380
? 1 2199
? 603 2199
? 1 60...

result:

ok Correct (18 test cases)

Test #16:

score: 0
Accepted
time: 31ms
memory: 31612kb

input:

1
1000000
999998
1000000
333334
333333
111111
111110
36086
36085
10279
10278
3514
3513
930
929
320
319
87
86
32
31
11
10
3
2

output:

? 1 1000000
? 333335 1000000
? 1 333334
? 111112 333334
? 1 111111
? 36087 111111
? 1 36086
? 10280 36086
? 1 10279
? 3515 10279
? 1 3514
? 931 3514
? 1 930
? 321 930
? 1 320
? 88 320
? 1 87
? 33 87
? 1 32
? 12 32
? 1 11
? 4 11
? 1 3
? 2 3
! 1

result:

ok Correct (1 test case)

Test #17:

score: 0
Accepted
time: 44ms
memory: 29236kb

input:

1994
667
666
454
27
27
27
27
27
28
2
2
2
2
2
374
372
224
91
96
29
29
16
12
8
5
3
2
488
485
161
83
83
44
15
15
14
6
7
3
2
922
921
662
40
40
40
40
40
51
18
12
7
8
3
2
639
639
421
147
95
68
55
2
2
2
2
2
2
353
351
200
91
81
27
22
2
2
2
2
2
71
71
47
6
6
6
8
3
2
24
22
24
7
3
2
567
563
205
3
3
3
3
3
3
3
3
...

output:

? 1 667
? 223 667
? 1 222
? 1 144
? 1 89
? 1 55
? 1 34
? 14 34
? 1 13
? 1 8
? 1 5
? 1 3
? 1 2
! 1
? 1 374
? 142 374
? 1 141
? 53 141
? 1 52
? 1 34
? 14 34
? 1 13
? 6 13
? 1 5
? 3 5
? 1 2
! 1
? 1 488
? 120 488
? 1 119
? 1 89
? 35 89
? 1 34
? 1 21
? 9 21
? 1 8
? 4 8
? 1 3
? 2 3
! 1
? 1 922
? 313 922
?...

result:

ok Correct (1994 test cases)

Test #18:

score: 0
Accepted
time: 33ms
memory: 30140kb

input:

18
153667
153667
50668
27244
27244
25988
8350
5820
1644
1644
1499
306
306
306
198
24
24
24
24
16
12
11
3
3
2
211376
211375
91641
67652
36438
4235
4235
4235
4235
3075
973
973
973
961
221
221
163
79
60
10
10
10
8
2
2
2
195330
195325
161600
36944
36944
17928
1018
1018
1018
1018
1018
1018
1568
281
281
2...

output:

? 1 153667
? 42749 153667
? 1 42748
? 1 28657
? 10947 28657
? 1 10946
? 4182 10946
? 1 4181
? 1 2584
? 988 2584
? 1 987
? 1 610
? 1 377
? 145 377
? 1 144
? 1 89
? 1 55
? 1 34
? 14 34
? 1 13
? 6 13
? 1 5
? 1 3
? 2 3
! 1
? 1 211376
? 70460 211376
? 1 70459
? 24092 70459
? 1 24091
? 1 17711
? 1 10946
?...

result:

ok Correct (18 test cases)

Test #19:

score: 0
Accepted
time: 35ms
memory: 27472kb

input:

1
1000000
999998
783271
169408
169408
188270
8002
8002
8002
8002
8002
6079
1522
1522
1522
1121
42
42
42
42
42
42
43
18
13
4
4
3
2

output:

? 1 1000000
? 333335 1000000
? 1 333334
? 1 222223
? 74076 222223
? 1 74075
? 1 46368
? 1 28657
? 1 17711
? 1 10946
? 4182 10946
? 1 4181
? 1 2584
? 1 1597
? 611 1597
? 1 610
? 1 377
? 1 233
? 1 144
? 1 89
? 1 55
? 22 55
? 1 21
? 9 21
? 1 8
? 1 5
? 3 5
? 1 2
! 1

result:

ok Correct (1 test case)

Test #20:

score: 0
Accepted
time: 34ms
memory: 25976kb

input:

1
999999
260772
507886
955966
996647
730076
730076
730076
717528
706326
705072
701051
701051
701051
700204
702009
701978
701202
701331
701453
701460
701361
701361
701361
701361
701361
701359
701356
701356

output:

? 1 999999
? 1 666666
? 666667 999999
? 777778 999999
? 666667 777777
? 666667 741691
? 695324 741691
? 713035 741691
? 695324 713034
? 702089 713034
? 695324 702088
? 697908 702088
? 699505 702088
? 699505 701101
? 701102 702088
? 701479 702088
? 701102 701478
? 701102 701334
? 701335 701478
? 7013...

result:

ok Correct (1 test case)

Test #21:

score: 0
Accepted
time: 45ms
memory: 29384kb

input:

1
999998
295598
295598
73514
537464
537464
537464
537464
537464
537464
537464
537464
537464
537464
536777
535839
535839
536097
536275
536275
536275
536271
536208
536208
536209
536195
536195
536197
536198

output:

? 1 999998
? 1 666665
? 1 501293
? 501294 666665
? 501294 622686
? 501294 576318
? 501294 547661
? 519005 547661
? 529951 547661
? 529951 540896
? 534132 540896
? 534132 538312
? 535729 538312
? 536716 538312
? 535729 536715
? 535729 536338
? 535729 536105
? 536106 536338
? 536195 536338
? 536195 53...

result:

ok Correct (1 test case)

Test #22:

score: 0
Accepted
time: 33ms
memory: 27648kb

input:

1
999997
339297
339297
339297
339297
355318
489939
489939
471212
453304
453304
453304
453304
453304
453304
453304
453304
453304
453304
453247
453059
453059
453059
453052
453017
453017
453013
453005
453007
453009

output:

? 1 999997
? 1 666664
? 1 501291
? 183481 501291
? 183481 379898
? 379899 501291
? 426267 501291
? 454924 501291
? 426267 454923
? 437213 454923
? 443978 454923
? 448159 454923
? 450743 454923
? 450743 453326
? 451730 453326
? 452340 453326
? 452717 453326
? 452950 453326
? 453094 453326
? 452950 45...

result:

ok Correct (1 test case)

Test #23:

score: 0
Accepted
time: 32ms
memory: 31232kb

input:

1
999996
578161
472988
726172
726172
722385
839217
839217
821597
853100
853969
859775
859775
859775
859775
859775
859775
859584
859300
859300
859303
859239
859239
859239
859239
859239
859239
859237
859235

output:

? 1 999996
? 1 666664
? 666665 999996
? 666665 888885
? 666665 814811
? 814812 888885
? 814812 861179
? 814812 843468
? 843469 861179
? 843469 854414
? 854415 861179
? 856999 861179
? 858596 861179
? 858596 860192
? 859206 860192
? 859206 859815
? 859439 859815
? 859206 859438
? 859206 859349
? 8592...

result:

ok Correct (1 test case)

Test #24:

score: 0
Accepted
time: 40ms
memory: 30596kb

input:

2
500000
114103
114103
98381
290103
281943
220637
207866
242095
237265
226042
226042
226042
226572
227371
227359
227012
227043
226739
226686
226805
226799
226770
226764
226777
226777
226777
226776
500000
313297
313297
313297
313297
246160
217669
198510
238712
235197
230101
228136
227098
227313
22604...

output:

? 1 500000
? 1 317811
? 1 196418
? 196419 317811
? 242787 317811
? 196419 242786
? 196419 225075
? 225076 242786
? 231841 242786
? 225076 231840
? 225076 229256
? 225076 227659
? 225076 226672
? 226673 227659
? 227050 227659
? 226673 227049
? 226817 227049
? 226673 226816
? 226673 226761
? 226762 22...

result:

ok Correct (2 test cases)

Test #25:

score: 0
Accepted
time: 29ms
memory: 30060kb

input:

2
499999
493493
493493
493493
493493
493493
493493
487773
471068
471068
471068
471068
470935
468187
467811
467320
467320
467320
467320
467277
467382
467361
467345
467345
467345
467344
467342
467341
499999
101651
101651
101651
101651
98374
24247
24247
18123
9237
9237
8975
6574
6338
4671
4671
4669
426...

output:

? 1 499999
? 182189 499999
? 303582 499999
? 378607 499999
? 424975 499999
? 453632 499999
? 471343 499999
? 453632 471342
? 460397 471342
? 464578 471342
? 467162 471342
? 468759 471342
? 467162 468758
? 467772 468758
? 467162 467771
? 467162 467538
? 467162 467394
? 467251 467394
? 467251 467339
?...

result:

ok Correct (2 test cases)

Test #26:

score: 0
Accepted
time: 27ms
memory: 30140kb

input:

2
499998
367462
193038
152483
89479
53076
53076
53076
49244
37492
37153
42856
42864
39670
39405
40342
40342
40342
40342
40342
40331
40280
40275
40296
40293
40290
40289
40291
499998
122343
122343
3768
313385
313385
278240
246144
246144
246144
244788
252131
251090
252602
253046
253610
253610
253602
25...

output:

? 1 499998
? 182188 499998
? 1 182187
? 60795 182187
? 1 60794
? 14427 60794
? 32138 60794
? 43084 60794
? 32138 43083
? 32138 38902
? 38903 43083
? 40500 43083
? 38903 40499
? 38903 39889
? 39890 40499
? 40123 40499
? 40123 40355
? 40212 40355
? 40267 40355
? 40301 40355
? 40267 40300
? 40267 40287...

result:

ok Correct (2 test cases)

Test #27:

score: 0
Accepted
time: 39ms
memory: 25876kb

input:

2
499997
274071
274071
274071
302688
167121
167121
159831
135636
135636
135636
135636
134277
133612
133655
132428
132396
132781
132781
132781
132803
132735
132725
132743
132740
132750
132748
132746
499997
242708
242708
242708
242708
177106
160791
160791
160791
155072
164685
164685
164685
164155
1630...

output:

? 1 499997
? 1 317811
? 121394 317811
? 196419 317811
? 121394 196418
? 121394 167761
? 139105 167761
? 121394 139104
? 128159 139104
? 132340 139104
? 132340 136520
? 133937 136520
? 132340 133936
? 132950 133936
? 132340 132949
? 132340 132716
? 132717 132949
? 132717 132860
? 132717 132805
? 1327...

result:

ok Correct (2 test cases)

Test #28:

score: 0
Accepted
time: 56ms
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 7
? 1 8
? 1 5
? 6 8
? 7 8
! 6
? 1 8
? 1 5
? 6 8
? 6 7
! 6
? 1 8
? 1 5
? 6 8
? 6 7
! 8
? 1 8
? 1 5
? 6 8
? 7 8
! 7
? 1 8
? 1 5
? 6 8
? 6 7
! 8
? 1 8
? 1 5
? 6 8
? 6 7
! 7
? 1 8
? 1 5
? 6 8
? 7 8
! 6
? 1 8
? 1 5
? 6 8
? 6 7
! 6
? 1 8
? 1 5
? 1 3
? ...

result:

ok Correct (10000 test cases)

Test #30:

score: 0
Accepted
time: 57ms
memory: 28012kb

input:

10000
8
2
3
7
6
8
2
3
8
8
8
2
3
6
7
8
2
3
6
6
8
2
3
8
7
8
2
3
7
7
8
2
3
7
6
8
2
3
8
8
8
2
3
6
7
8
2
3
6
6
8
2
3
8
7
8
2
3
7
7
8
2
5
7
6
8
2
5
8
8
8
2
5
6
7
8
2
5
6
6
8
2
5
8
7
8
2
5
7
7
8
2
2
3
4
8
2
2
3
4
8
2
2
3
4
8
2
2
3
4
8
2
2
3
4
8
2
2
3
4
8
2
4
7
6
8
2
4
8
8
8
2
4
6
7
8
2
4
6
6
8
2
4
8
7
8
2
...

output:

? 1 8
? 1 5
? 6 8
? 6 7
! 8
? 1 8
? 1 5
? 6 8
? 7 8
! 7
? 1 8
? 1 5
? 6 8
? 6 7
! 8
? 1 8
? 1 5
? 6 8
? 6 7
! 7
? 1 8
? 1 5
? 6 8
? 7 8
! 6
? 1 8
? 1 5
? 6 8
? 6 7
! 6
? 1 8
? 1 5
? 6 8
? 6 7
! 8
? 1 8
? 1 5
? 6 8
? 7 8
! 7
? 1 8
? 1 5
? 6 8
? 6 7
! 8
? 1 8
? 1 5
? 6 8
? 6 7
! 7
? 1 8
? 1 5
? 6 8
? ...

result:

ok Correct (10000 test cases)

Test #31:

score: 0
Accepted
time: 58ms
memory: 28720kb

input:

10000
8
2
4
8
7
8
2
4
7
7
8
2
2
1
4
8
2
2
1
4
8
2
2
1
4
8
2
2
1
4
8
2
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 7
! 8
? 1 8
? 1 5
? 6 8
? 7 8
! 7
? 1 8
? 1 5
? 6 8
? 6 7
! 8
? 1 8
? 1 5
? 6 8
? 6 7
! 7
? 1 8
? 1 5
? 6 8
? 7 8
! 6
? 1 8
? 1 5
? 6 8
? 6 7
! 6
? 1 8
? 1 5
? 1 3
? ...

result:

ok Correct (10000 test cases)

Test #33:

score: 0
Accepted
time: 52ms
memory: 28456kb

input:

10000
9
3
8
9
3
3
5
7
6
9
3
7
9
3
3
5
7
6
9
3
3
5
8
8
9
3
3
5
8
8
9
3
8
9
3
3
5
6
7
9
3
7
9
3
3
5
7
6
9
3
3
5
6
6
9
3
3
5
8
8
9
3
6
9
3
3
5
6
7
9
3
6
9
3
3
5
6
7
9
3
3
5
6
6
9
3
3
5
6
6
9
3
3
5
8
7
9
3
3
5
8
7
9
3
3
5
7
7
9
3
3
5
8
7
9
3
3
5
7
7
9
3
3
5
7
7
9
3
5
9
3
3
5
7
6
9
3
5
9
3
3
5
7
6
9
3
3
...

output:

? 1 9
? 1 8
! 9
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 8
? 1 9
? 1 8
! 9
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 8
? 1 9
? 1 8
? 1 5
? 6 8
? 7 8
! 7
? 1 9
? 1 8
? 1 5
? 6 8
? 7 8
! 7
? 1 9
? 1 8
! 9
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 8
? 1 9
? 1 8
! 9
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 8
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! ...

result:

ok Correct (10000 test cases)

Test #34:

score: 0
Accepted
time: 86ms
memory: 30308kb

input:

10000
9
3
3
5
6
6
9
3
3
5
6
6
9
3
3
5
8
7
9
3
3
5
8
7
9
3
3
5
7
7
9
3
3
5
8
7
9
3
3
5
7
7
9
3
3
5
7
7
9
3
3
3
2
4
9
3
3
3
2
4
9
3
3
3
2
4
9
3
3
3
2
4
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7
! 8
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 7
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 7
? 1 9
? 1 8
? ...

result:

ok Correct (10000 test cases)

Test #36:

score: 0
Accepted
time: 80ms
memory: 30060kb

input:

10000
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
2
3
5
9
2
2
...

output:

? 1 9
? 1 8
? 1 5
? 1 3
? 4 5
! 4
? 1 9
? 1 8
? 1 5
? 1 3
? 4 5
! 4
? 1 9
? 1 8
? 1 5
? 1 3
? 4 5
! 4
? 1 9
? 1 8
? 1 5
? 1 3
? 4 5
! 4
? 1 9
? 1 8
? 1 5
? 1 3
? 4 5
! 4
? 1 9
? 1 8
? 1 5
? 1 3
? 4 5
! 4
? 1 9
? 1 8
? 1 5
? 1 3
? 4 5
! 4
? 1 9
? 1 8
? 1 5
? 1 3
? 4 5
! 4
? 1 9
? 1 8
? 1 5
? 1 3
? 4 ...

result:

ok Correct (10000 test cases)

Test #37:

score: 0
Accepted
time: 121ms
memory: 32024kb

input:

10000
9
4
4
3
6
6
9
4
4
3
6
6
9
4
4
3
8
7
9
4
4
3
8
7
9
4
4
3
7
7
9
4
4
3
8
7
9
4
4
3
7
7
9
4
4
3
7
7
9
4
4
4
4
3
9
4
4
4
4
3
9
4
4
4
4
3
9
4
4
4
4
3
9
4
4
4
4
3
9
4
4
4
4
3
9
4
4
4
4
3
9
4
4
4
4
3
9
4
4
4
4
3
9
4
4
4
4
3
9
4
4
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9
? 1 8
? ...

result:

ok Correct (10000 test cases)

Test #39:

score: 0
Accepted
time: 70ms
memory: 31164kb

input:

10000
9
8
3
9
9
9
9
9
9
9
7
3
9
7
7
7
7
6
9
9
9
9
9
8
9
8
8
8
8
8
9
8
3
9
9
9
9
9
9
9
7
3
9
7
7
7
7
6
9
9
9
9
9
8
9
8
8
8
8
8
9
6
3
9
6
6
6
4
7
9
6
3
9
6
6
6
4
7
9
6
6
6
4
8
9
6
6
6
4
8
9
9
9
9
8
5
9
8
8
8
8
7
9
9
9
9
7
5
9
8
8
8
8
7
9
7
7
7
7
7
9
7
7
7
7
7
9
5
3
9
5
5
3
7
6
9
5
3
9
5
5
3
7
6
9
5
5
...

output:

? 1 9
? 1 8
! 9
? 1 9
? 2 9
? 5 9
? 7 9
? 8 9
! 8
? 1 9
? 1 8
! 9
? 1 9
? 1 8
? 4 8
? 6 8
? 6 7
! 8
? 1 9
? 2 9
? 5 9
? 7 9
? 8 9
! 7
? 1 9
? 1 8
? 4 8
? 6 8
? 7 8
! 7
? 1 9
? 1 8
! 9
? 1 9
? 2 9
? 5 9
? 7 9
? 8 9
! 8
? 1 9
? 1 8
! 9
? 1 9
? 1 8
? 4 8
? 6 8
? 6 7
! 8
? 1 9
? 2 9
? 5 9
? 7 9
? 8 9
! ...

result:

ok Correct (10000 test cases)

Test #40:

score: 0
Accepted
time: 80ms
memory: 30628kb

input:

10000
9
2
2
5
6
6
9
2
2
5
6
6
9
2
2
5
8
7
9
2
2
5
8
7
9
2
2
5
7
7
9
2
2
5
8
7
9
2
2
5
7
7
9
2
2
5
7
7
9
2
2
2
3
4
9
2
2
2
3
4
9
2
2
2
3
4
9
2
2
2
3
4
9
2
2
2
3
4
9
2
2
2
3
4
9
2
2
2
3
4
9
2
2
2
3
4
9
2
2
2
3
4
9
2
2
2
3
4
9
2
2
2
3
4
9
2
2
2
3
4
9
2
2
2
3
4
9
2
2
2
3
4
9
2
2
2
3
4
9
2
2
2
3
4
9
2
2
...

output:

? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 7
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 7
? 1 9
? 1 8
? 1 5
? 6 8
? 7 8
! 6
? 1 9
? 1 8
? 1 5
? 6 8
? 7 8
! 6
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 6
? 1 9
? 1 8
? 1 5
? 6 8
? 7 8
! 6
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 6
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 6
? 1 9
? 1 8
? 1 5
? 1 3
? 4 ...

result:

ok Correct (10000 test cases)

Test #41:

score: 0
Accepted
time: 90ms
memory: 30496kb

input:

10000
9
7
3
9
7
7
7
7
6
9
9
9
9
9
8
9
8
8
8
8
8
9
6
3
9
6
6
6
4
7
9
6
3
9
6
6
6
4
7
9
6
6
6
4
8
9
6
6
6
4
8
9
9
9
9
8
5
9
8
8
8
8
7
9
9
9
9
7
5
9
8
8
8
8
7
9
7
7
7
7
7
9
7
7
7
7
7
9
8
3
9
9
9
9
9
9
9
7
3
9
7
7
7
7
6
9
9
9
9
9
8
9
8
8
8
8
8
9
8
3
9
9
9
9
9
9
9
7
3
9
7
7
7
7
6
9
9
9
9
9
8
9
8
8
8
8
8
...

output:

? 1 9
? 1 8
! 9
? 1 9
? 1 8
? 4 8
? 6 8
? 6 7
! 8
? 1 9
? 2 9
? 5 9
? 7 9
? 8 9
! 7
? 1 9
? 1 8
? 4 8
? 6 8
? 7 8
! 7
? 1 9
? 1 8
! 9
? 1 9
? 1 8
? 4 8
? 4 6
? 7 8
! 8
? 1 9
? 1 8
! 9
? 1 9
? 1 8
? 4 8
? 4 6
? 7 8
! 8
? 1 9
? 1 8
? 4 8
? 4 6
? 7 8
! 7
? 1 9
? 1 8
? 4 8
? 4 6
? 7 8
! 7
? 1 9
? 2 9
? ...

result:

ok Correct (10000 test cases)

Test #42:

score: 0
Accepted
time: 79ms
memory: 30716kb

input:

10000
9
8
3
9
9
9
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 1 5
? 6 8
? 7 8
! 6
? 1 9
? 1 8
? 1 5
? 6 8
? 7 8
! 6
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 6
? 1 9
? 1 8
? 1 5
? 6 8
? 7 8
! 6
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 6
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 6
? 1 9
? 2 9
? 5 9
? 7 9
? 5 ...

result:

ok Correct (10000 test cases)

Test #44:

score: 0
Accepted
time: 68ms
memory: 25924kb

input:

10000
9
2
7
9
2
2
3
7
6
9
2
2
3
6
6
9
2
2
3
8
8
9
2
6
9
2
2
3
6
7
9
2
6
9
2
2
3
6
7
9
2
2
3
6
6
9
2
2
3
6
6
9
2
2
3
8
7
9
2
2
3
8
7
9
2
2
3
7
7
9
2
2
3
8
7
9
2
2
3
7
7
9
2
2
3
7
7
9
2
8
9
2
2
3
7
6
9
2
7
9
2
2
3
7
6
9
2
2
3
8
8
9
2
2
3
8
8
9
2
8
9
2
2
3
6
7
9
2
7
9
2
2
3
7
6
9
2
2
3
6
6
9
2
2
3
8
8
...

output:

? 1 9
? 1 8
! 9
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 8
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 7
? 1 9
? 1 8
? 1 5
? 6 8
? 7 8
! 7
? 1 9
? 1 8
! 9
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 8
? 1 9
? 1 8
! 9
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 8
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 7
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 7
? 1 9
? 1 8
? ...

result:

ok Correct (10000 test cases)

Test #45:

score: 0
Accepted
time: 92ms
memory: 31612kb

input:

10000
9
9
9
8
3
2
9
8
8
8
7
5
9
9
9
7
3
2
9
8
8
8
7
5
9
7
7
7
8
5
9
7
7
7
8
5
9
9
9
8
3
2
9
8
8
8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
? 6 7
! 6
? 1 9
? 1 8
? 1 5
? 6 8
? 7 8
! 6
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 6
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 6
? 1 9
? 1 8
? 1 5
? 3 5
? 3 ...

result:

ok Correct (10000 test cases)

Test #47:

score: 0
Accepted
time: 91ms
memory: 27852kb

input:

10000
9
4
7
9
4
4
2
7
6
9
4
4
2
6
6
9
4
4
2
8
8
9
4
6
9
4
4
2
6
7
9
4
6
9
4
4
2
6
7
9
4
4
2
6
6
9
4
4
2
6
6
9
4
4
2
8
7
9
4
4
2
8
7
9
4
4
2
7
7
9
4
4
2
8
7
9
4
4
2
7
7
9
4
4
2
7
7
9
4
8
9
4
4
2
7
6
9
4
7
9
4
4
2
7
6
9
4
4
2
8
8
9
4
4
2
8
8
9
4
8
9
4
4
2
6
7
9
4
7
9
4
4
2
7
6
9
4
4
2
6
6
9
4
4
2
8
8
...

output:

? 1 9
? 1 8
! 9
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 8
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 7
? 1 9
? 1 8
? 1 5
? 6 8
? 7 8
! 7
? 1 9
? 1 8
! 9
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 8
? 1 9
? 1 8
! 9
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 8
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 7
? 1 9
? 1 8
? 1 5
? 6 8
? 6 7
! 7
? 1 9
? 1 8
? ...

result:

ok Correct (10000 test cases)

Extra Test:

score: 0
Extra Test Passed