//! # Bundled libraries //! //! - `mario v0.1.0` → `crate::mario` (source: local filesystem, license: **missing**) use mario::*; use std::io::*; fn main() { let mut io = MarIo::new_stdio(); let (a, b, c, d) = read!(io: i64, i64, i64, i64); if a == c || b == d || (a - c).abs() + (b - d).abs() <= 3 { writeln!(io, "{}", 1).unwrap(); } else { writeln!(io, "{}", 2).unwrap(); } } // The following code was expanded by `cargo-equip`. #[allow(unused)] pub mod mario { pub use crate::read; use std::io; use std::io::{BufRead, BufReader, BufWriter, ErrorKind, Result, Write}; pub mod token { use std::str::FromStr; pub trait Token { type Output; fn parse(s: &str) -> Self::Output; } impl Token for T { type Output = T; fn parse(s: &str) -> Self::Output { s.parse::().unwrap_or_else(|_| panic!("Parse Error")) } } #[allow(non_camel_case_types)] pub struct usize1(); impl Token for usize1 { type Output = usize; fn parse(s: &str) -> Self::Output { let i = s.parse::().unwrap_or_else(|_| panic!("Parse Error")); i.checked_sub(1).unwrap() } } #[allow(non_camel_case_types)] pub struct isize1(); impl Token for isize1 { type Output = isize; fn parse(s: &str) -> Self::Output { let i = s.parse::().unwrap_or_else(|_| panic!("Parse Error")); i.checked_sub(1).unwrap() } } } use token::Token; fn read_until_whitespace(r: &mut R, buf: &mut Vec) -> Result { let mut read = 0; loop { let (done, used) = { let available = match r.fill_buf() { Ok(n) => n, Err(ref e) if e.kind() == ErrorKind::Interrupted => continue, Err(e) => return Err(e), }; match available .iter() .enumerate() .find(|(_, x)| x.is_ascii_whitespace()) { Some((i, _)) => { buf.extend_from_slice(&available[..=i]); (true, i + 1) } None => { buf.extend_from_slice(available); (false, available.len()) } } }; r.consume(used); read += used; if done || used == 0 { return Ok(read); } } } macro_rules! prim_method { ($name:ident: $T:ty) => { pub fn $name(&mut self) -> $T { self.parse::<$T>() } }; ($name:ident) => { prim_method!($name: $name); }; } macro_rules! prim_methods { ($name:ident: $T:ty; $($rest:tt)*) => { prim_method!($name:$T); prim_methods!($($rest)*); }; ($name:ident; $($rest:tt)*) => { prim_method!($name); prim_methods!($($rest)*); }; () => () } // MARimo + IO -> MarIo pub struct MarIo { reader: I, writer: BufWriter, } impl MarIo { pub fn new(reader: I, writer: O) -> Self { Self { reader, writer: BufWriter::new(writer), } } fn token(&mut self) -> String { let mut buf = Vec::new(); loop { buf.clear(); read_until_whitespace(&mut self.reader, &mut buf) .expect("困ってしまいましたね。どうやら入力がうまくいかないようです。"); let len = buf.len(); match len { 0 => panic!("もう入力終わってますよ。"), 1 if buf[0].is_ascii_whitespace() => (), _ => { if buf[len - 1].is_ascii_whitespace() { buf.truncate(len - 1); } break; } } } unsafe { String::from_utf8_unchecked(buf) } } pub fn parse(&mut self) -> T::Output { T::parse(&self.token()) } prim_methods! { u8; u16; u32; u64; u128; usize; i8; i16; i32; i64; i128; isize; f32; f64; char; string: String; } } // MarIo with stdin/out impl MarIo, io::Stdout> { pub fn new_stdio() -> Self { Self::new(BufReader::new(io::stdin()), io::stdout()) } } // MarIo with stdinlock/stdoutlock impl MarIo, io::StdoutLock<'static>> { pub unsafe fn new_stdinlock() -> Self { let stdin = Box::leak(Box::new(io::stdin())); let stdout = Box::leak(Box::new(io::stdout())); Self::new(stdin.lock(), stdout.lock()) } } impl Write for MarIo { fn write(&mut self, buf: &[u8]) -> Result { self.writer.write(buf) } fn flush(&mut self) -> Result<()> { self.writer.flush() } } #[macro_export] macro_rules! read { ($stdin:ident: [char]) => { $stdin.string().chars().collect::>() }; ($stdin:ident: [u8]) => { $stdin.string().bytes().collect::>() }; ($stdin:ident: [$($t:tt),*; $n:expr]) => { (0..$n).map(|_| ($(read!($stdin: $t)),*)).collect::>() }; ($stdin:ident: $t:ty) => { $stdin.parse::<$t>() }; ($stdin:ident: $($t:ty),+) => { ($(read!($stdin: $t)),*) }; } }