use std::io; use std::error::Error; use std::fmt; type Result = std::result::Result>; enum State { Dead, Survived, } impl fmt::Display for State { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { State::Dead => write!(f, "DEAD"), State::Survived => write!(f, "SURVIVED"), } } } fn get_line() -> Result { let mut input = String::new(); try!(io::stdin().read_line(&mut input)); Ok(input) } fn read_flags(input: String) -> Result<(u8, u8, u8, u8)> { let flags: Vec<&str> = input.trim().split(' ').collect(); Ok((try!(flags[0].parse()), try!(flags[1].parse()), try!(flags[2].parse()), try!(flags[3].parse()))) } fn check_dead_or_live(d1: u8, d2: u8, d3: u8, s: u8) -> State { if s == 1 { return State::Survived; } if (d1 + d2 + d3) < 2 { return State::Survived; } State::Dead } fn main() { let (d1, d2, d3, s) = get_line().and_then(read_flags).unwrap(); println!("{}", check_dead_or_live(d1, d2, d3, s)); }