fn main() { scan!(s: char); println!("{}", match s { 'E' => "F".to_string(), 'B' => "C".to_string(), c => format!("{}{}", c, '#') }) } mod iolib { use std::cell::RefCell; use std::io::{ Read, BufRead, Error }; use std::str::SplitWhitespace; use std::thread_local; thread_local! { static BUF_SPLIT_WHITESPACE: RefCell> = RefCell::new("".split_whitespace()); } #[inline] fn refill_buffer(interactive: bool) -> Result<(), Error> { let mut s = String::new(); if cfg!(debug_assertions) || interactive { std::io::stdin().lock().read_line(&mut s)?; } else { std::io::stdin().lock().read_to_string(&mut s)?; } BUF_SPLIT_WHITESPACE.with(|buf_str| { *buf_str.borrow_mut() = Box::leak(s.into_boxed_str()).split_whitespace(); Ok(()) }) } #[inline] pub fn scan_string(interactive: bool) -> &'static str { BUF_SPLIT_WHITESPACE.with(|buf_str| { if let Some(s) = buf_str.borrow_mut().next() { return s; } refill_buffer(interactive).unwrap(); if let Some(s) = buf_str.borrow_mut().next() { return s; } unreachable!("Read Error: No input items."); }) } #[macro_export] macro_rules! scan { // Terminator ( @interactive : $interactive:literal ) => {}; // Terminator ( @interactive : $interactive:literal, ) => {}; // Vec> ( @interactive : $interactive:literal, $v: ident : [ [ $( $inner:tt )+ ] ; $len:expr ]) => { let $v = { let len = $len; (0..len).fold(vec![], |mut v, _| { $crate::scan!(@interactive: $interactive, w: [ $( $inner )+ ]); v.push(w); v }) }; }; // Vec>, ...... ( @interactive : $interactive:literal, $v: ident : [ [ $( $inner:tt )+ ] ; $len:expr ] , $( $rest:tt )* ) => { $crate::scan!(@interactive: $interactive, [ [ $( $inner )+ ] ; $len ]); $crate::scan!(@interactive: $interactive, $( $rest )*); }; // Vec<$t> ( @interactive : $interactive:literal, $v:ident : [ $t:tt ; $len:expr ]) => { let $v = { let len = $len; (0..len).map(|_| { $crate::scan!(@interactive: $interactive, $v : $t); $v }).collect::>() }; }; // Vec<$t>, ..... ( @interactive : $interactive:literal, $v:ident : [ $t:tt ; $len:expr ] , $( $rest:tt )* ) => { let $v = { let len = $len; (0..len).map(|_| { $crate::scan!(@interactive: $interactive, $v : $t); $v }).collect::>() }; $crate::scan!(@interactive: $interactive, $( $rest )*); }; // Expand tuple ( @interactive : $interactive:literal, @expandtuple, ( $t:tt )) => { { let tmp = $crate::iolib::scan_string($interactive).parse::<$t>().unwrap(); tmp } }; // Expand tuple ( @interactive : $interactive:literal, @expandtuple, ( $t:tt $( , $rest:tt )* ) ) => { ( $crate::scan!(@interactive: $interactive, @expandtuple, ( $t )), $( $crate::scan!(@interactive: $interactive, @expandtuple, ( $rest )), )* ) }; // let $v: ($t, $u, ....) = (.......) ( @interactive : $interactive:literal, $v:ident : ( $( $rest:tt )* ) ) => { let $v = $crate::scan!(@interactive: $interactive, @expandtuple, ( $( $rest )* )); }; // let $v: $t = ...... ( @interactive : $interactive:literal, $v:ident : $t:ty ) => { let $v = $crate::iolib::scan_string($interactive).parse::<$t>().unwrap(); }; // let $v: $t = ......, ....... ( @interactive : $interactive:literal, $v:ident : $t:ty, $( $rest:tt )+ ) => { $crate::scan!(@interactive: $interactive, $v : $t); $crate::scan!(@interactive: $interactive, $( $rest )+); }; // ...... ( $( $rest:tt )* ) => { $crate::scan!(@interactive: false, $( $rest )*); }; } #[macro_export] macro_rules! scani { ( $( $rest:tt )* ) => { $crate::scan!(@interactive: true, $( $rest )*); }; } }