Submit Info #68403

Problem Lang User Status Time Memory
Associative Array rust dalt AC 230 ms 38.83 MiB

ケース詳細
Name Status Time Memory
2_powers_00 AC 204 ms 35.32 MiB
example_00 AC 0 ms 0.42 MiB
many_0set_00 AC 230 ms 37.12 MiB
many_0set_sparse_00 AC 48 ms 2.86 MiB
max_random_00 AC 221 ms 38.83 MiB
max_random_01 AC 213 ms 38.50 MiB
max_random_02 AC 207 ms 38.03 MiB
random_00 AC 66 ms 9.77 MiB
random_01 AC 88 ms 18.62 MiB
random_02 AC 108 ms 18.58 MiB
sparse_keys_00 AC 51 ms 4.54 MiB
sparse_keys_01 AC 60 ms 5.56 MiB
unordered_map_killer_00 AC 188 ms 35.27 MiB
unordered_map_killer_01 AC 188 ms 35.29 MiB
unordered_map_killer_02 AC 191 ms 35.31 MiB

pub mod util { pub mod io { use std :: io ; # [ doc = "\r" ] # [ doc = " Fast input for competitive programming\r" ] # [ doc = "\r" ] # [ doc = " # Unsafe\r" ] # [ doc = "\r" ] # [ doc = " Only support ascii\r" ] # [ doc = "\r" ] # [ doc = " # Example\r" ] # [ doc = "\r" ] # [ doc = " ```not_run\r" ] # [ doc = " let mut stdin = io::stdin();\r" ] # [ doc = " let mut fi = FastInput::new(stdin.lock());\r" ] # [ doc = " ```\r" ] # [ doc = "\r" ] # [ doc = "\r" ] pub struct FastInput < R : std :: io :: BufRead > { inner : R , line : Vec < u8 > , offset : usize , } impl < R : std :: io :: BufRead > FastInput < R > { pub fn new ( inner : R ) -> Self { FastInput { inner , line : Vec :: with_capacity ( 1 << 15 ) , offset : 0 , } } # [ doc = "\r" ] # [ doc = " Read next token of current processed line\r" ] # [ doc = "\r" ] fn next ( & mut self ) -> Option < & str > { while self . offset < self . line . len ( ) && self . line [ self . offset ] <= 32 { self . offset += 1 ; } if self . offset == self . line . len ( ) { return None ; } let begin = self . offset ; let mut end = self . offset + 1 ; while end < self . line . len ( ) && self . line [ end ] > 32 { end += 1 ; } self . offset = end ; unsafe { Some ( std :: str :: from_utf8_unchecked ( & self . line [ begin .. end ] ) ) } } # [ doc = "\r" ] # [ doc = " Read a specified type element from input\r" ] # [ doc = "\r" ] # [ doc = " # Unsafe\r" ] # [ doc = "\r" ] # [ doc = " This method might enter infinite loop if no more input available\r" ] # [ doc = "\r" ] pub fn read < T : std :: str :: FromStr > ( & mut self ) -> T { loop { match self . next ( ) { Some ( token ) => { return token . parse ( ) . ok ( ) . expect ( "Wrong format input" ) ; } None => { self . line . clear ( ) ; self . inner . read_until ( b'\n' , & mut self . line ) ; self . offset = 0 ; } } } } pub fn ri ( & mut self ) -> i32 { let res : i32 = self . read ( ) ; return res ; } pub fn rl ( & mut self ) -> i64 { let res : i64 = self . read ( ) ; return res ; } pub fn rf ( & mut self ) -> f64 { let res : f64 = self . read ( ) ; return res ; } pub fn rs ( & mut self ) -> String { let res : String = self . read ( ) ; return res ; } } # [ cfg ( test ) ] mod tests { use std :: io :: { BufReader , Cursor , Read } ; use super :: FastInput ; # [ test ] fn test_read ( ) { let s = "123\n-4 -5\r abcd\n 1.5" ; let mut c = Cursor :: new ( s ) ; let mut reader = BufReader :: new ( c ) ; let mut reader = FastInput :: new ( reader ) ; assert_eq ! ( 123 , reader . read ( ) ) ; assert_eq ! ( - 4 , reader . read ( ) ) ; assert_eq ! ( - 5 , reader . read ( ) ) ; let x : String = reader . read ( ) ; assert_eq ! ( "abcd" . to_string ( ) , x ) ; assert_eq ! ( 1.5 , reader . read ( ) ) ; } } } } use std :: hash :: Hash ; use std :: io :: { BufWriter , StdinLock , StdoutLock , Write , BufRead } ; use std :: collections :: { self , HashMap } ; pub unsafe fn solve_one ( test_id : u32 , fi : & mut crate :: util :: io :: FastInput < StdinLock > , fo : & mut BufWriter < StdoutLock > ) { let q = fi . ri ( ) ; let mut map = HashMap :: with_capacity ( q as usize ) ; for i in 0 .. q { let t = fi . ri ( ) ; let k = fi . rl ( ) ; if t == 0 { let v = fi . rl ( ) ; map . insert ( k , v ) ; } else { let res = match map . get ( & k ) { Some ( v ) => v , None => & 0 , } ; writeln ! ( fo , "{}" , res ) ; } } } pub unsafe fn solve_multi ( fi : & mut crate :: util :: io :: FastInput < StdinLock > , fo : & mut BufWriter < StdoutLock > ) { let t : u32 = 1 ; for test_id in 1 .. t + 1 { solve_one ( test_id , fi , fo ) ; } } fn main ( ) { unsafe { let mut stdin = std :: io :: stdin ( ) ; let mut stdout = std :: io :: stdout ( ) ; let mut fi = util :: io :: FastInput :: new ( stdin . lock ( ) ) ; let mut fo = std :: io :: BufWriter :: new ( stdout . lock ( ) ) ; solve_multi ( & mut fi , & mut fo ) ; } }