fn next(n: usize, player: usize, reverse: bool) -> usize { if reverse { (n + player - 1) % n } else { (player + 1) % n } } fn main() { let mut nm = String::new(); std::io::stdin().read_line(&mut nm).ok(); let nm: Vec = nm.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n: usize = nm[0]; let m: usize = nm[1]; let mut cards: Vec = vec![0; n]; let mut reverse: bool = false; let mut player: usize = 0; let mut bombing2: bool = false; let mut bombing4: bool = false; let mut bombing_count: isize = 0; for i in 0..m { println!("{}", player+1); let mut card = String::new(); std::io::stdin().read_line(&mut card).ok(); let card: &str = card.trim(); if bombing2 { match card { "drawtwo" => {}, _ => { bombing2 = false; cards[player] += bombing_count; bombing_count = 0; player = next(n, player, reverse); }, } } if bombing4 { match card { "drawfour" => {}, _ => { bombing4 = false; cards[player] += bombing_count; bombing_count = 0; player = next(n, player, reverse); }, } } if i == m-1 { cards[player] += 1; break; } else { cards[player] += 1; match card { "drawtwo" => { bombing2 = true; bombing_count -= 2; }, "drawfour" => { bombing4 = true; bombing_count -= 4; }, "skip" => { player = next(n, player, reverse); }, "reverse" => { reverse = !reverse; }, _ => {}, } player = next(n, player, reverse); } } println!("{} {}", player+1, cards[player]); }