Submission #1404130


Source Code Expand

mod reader {
    use std::fmt::Debug;
    use std::str::FromStr;
    use std::collections::VecDeque;
    use std::io::{self, Read};

    fn _read_line() -> String {
        let mut buf = String::new();
        let _ = io::stdin().read_to_string(&mut buf);
        buf
    }

    fn _read_vec_deque_string() -> VecDeque<String> {
        _read_line()
            .split_whitespace()
            .map(|s| s.to_string())
            .collect()
    }

    #[allow(dead_code)]
    pub struct Reader {
        buf: VecDeque<String>,
    }

    #[allow(dead_code)]
    impl Reader {
        pub fn new() -> Reader {
            Reader { buf: VecDeque::new() }
        }

        fn update_buf(&mut self) {
            if self.buf.is_empty() {
                self.buf = _read_vec_deque_string();
            }
        }

        pub fn next<T>(&mut self) -> T
            where
                T: FromStr,
                T::Err: Debug,
        {
            self.update_buf();
            self.buf.pop_front().unwrap().parse::<T>().unwrap()
        }

        pub fn next_n<T>(&mut self, n: usize) -> Vec<T>
            where
                T: FromStr,
                T::Err: Debug,
        {
            let mut vec: Vec<T> = Vec::with_capacity(n);

            for _ in 0..n {
                vec.push(self.next());
            }
            vec
        }
    }
}

#[allow(unused_macros)]
macro_rules! p {
    ([$($x:expr), *]) => {{
        let mut f = true;
        $(
            print!("{}{}", if f {""} else {" "}, $x);
            f = false;
        )*
        print!("\n");
    }};
    ($x:expr) => {{
        let mut f = true;
        for a in $x.iter() {
            print!("{}{}", if f {""} else {" "}, a);
            f = false;
        }
        print!("\n");
    }};
}

fn main() {
    let mut r = reader::Reader::new();

    let a: i32 = r.next();
    let b: i32 = r.next();

    let f = |a| [a / 100, a % 100 / 10, a % 10];
    let g = |a, b, c| a * 100 + b * 10 + c;

    let c = f(a);
    let d = f(b);

    let mut v = vec![
        g(9, c[1], c[2]) - b,
        g(c[0], 9, c[2]) - b,
        g(c[0], c[1], 9) - b,
        a - g(1, d[1], d[2]),
        a - g(d[0], 0, d[2]),
        a - g(d[0], d[1], 0),
    ];

    v.sort();
    p!([v.last().unwrap()]);
}

Submission Info

Submission Time
Task A - A - B problem
User yuusti
Language Rust (1.15.1)
Score 100
Code Size 2378 Byte
Status AC
Exec Time 2 ms
Memory 4352 KB

Compile Error

warning: value assigned to `f` is never read, #[warn(unused_assignments)] on by default
   --> ./Main.rs:67:13
    |
67  |             f = false;
    |             ^
...
103 |     p!([v.last().unwrap()]);
    |     ------------------------ in this macro invocation

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 45
Set Name Test Cases
Sample sample_0.txt, sample_1.txt, sample_2.txt
All ansneg_0.txt, ansneg_1.txt, ansneg_2.txt, ansneg_3.txt, ansneg_4.txt, ansneg_5.txt, ansneg_6.txt, ansneg_7.txt, ansneg_8.txt, ansneg_9.txt, handmade_0.txt, handmade_1.txt, random_0.txt, random_1.txt, random_2.txt, random_3.txt, random_4.txt, random_5.txt, random_6.txt, random_7.txt, random_8.txt, random_9.txt, sample_0.txt, sample_1.txt, sample_2.txt, top2fixed_0.txt, top2fixed_1.txt, top2fixed_2.txt, top2fixed_3.txt, top2fixed_4.txt, top2fixed_5.txt, top2fixed_6.txt, top2fixed_7.txt, top2fixed_8.txt, top2fixed_9.txt, topfixed_0.txt, topfixed_1.txt, topfixed_2.txt, topfixed_3.txt, topfixed_4.txt, topfixed_5.txt, topfixed_6.txt, topfixed_7.txt, topfixed_8.txt, topfixed_9.txt
Case Name Status Exec Time Memory
ansneg_0.txt AC 2 ms 4352 KB
ansneg_1.txt AC 2 ms 4352 KB
ansneg_2.txt AC 2 ms 4352 KB
ansneg_3.txt AC 2 ms 4352 KB
ansneg_4.txt AC 2 ms 4352 KB
ansneg_5.txt AC 2 ms 4352 KB
ansneg_6.txt AC 2 ms 4352 KB
ansneg_7.txt AC 2 ms 4352 KB
ansneg_8.txt AC 2 ms 4352 KB
ansneg_9.txt AC 2 ms 4352 KB
handmade_0.txt AC 2 ms 4352 KB
handmade_1.txt AC 2 ms 4352 KB
random_0.txt AC 2 ms 4352 KB
random_1.txt AC 2 ms 4352 KB
random_2.txt AC 2 ms 4352 KB
random_3.txt AC 2 ms 4352 KB
random_4.txt AC 2 ms 4352 KB
random_5.txt AC 2 ms 4352 KB
random_6.txt AC 2 ms 4352 KB
random_7.txt AC 2 ms 4352 KB
random_8.txt AC 2 ms 4352 KB
random_9.txt AC 2 ms 4352 KB
sample_0.txt AC 2 ms 4352 KB
sample_1.txt AC 2 ms 4352 KB
sample_2.txt AC 2 ms 4352 KB
top2fixed_0.txt AC 2 ms 4352 KB
top2fixed_1.txt AC 2 ms 4352 KB
top2fixed_2.txt AC 2 ms 4352 KB
top2fixed_3.txt AC 2 ms 4352 KB
top2fixed_4.txt AC 2 ms 4352 KB
top2fixed_5.txt AC 2 ms 4352 KB
top2fixed_6.txt AC 2 ms 4352 KB
top2fixed_7.txt AC 2 ms 4352 KB
top2fixed_8.txt AC 2 ms 4352 KB
top2fixed_9.txt AC 2 ms 4352 KB
topfixed_0.txt AC 2 ms 4352 KB
topfixed_1.txt AC 2 ms 4352 KB
topfixed_2.txt AC 2 ms 4352 KB
topfixed_3.txt AC 2 ms 4352 KB
topfixed_4.txt AC 2 ms 4352 KB
topfixed_5.txt AC 2 ms 4352 KB
topfixed_6.txt AC 2 ms 4352 KB
topfixed_7.txt AC 2 ms 4352 KB
topfixed_8.txt AC 2 ms 4352 KB
topfixed_9.txt AC 2 ms 4352 KB