#![allow(unused_imports)] #![allow(unused_macros)] #![allow(dead_code)] #![allow(non_snake_case)] use std::collections::VecDeque; use std::fs::read; use std::io::Write; use std::time::Instant; const Y: usize = 60; const X: usize = 25; // src: https://yukicoder.me/submissions/892593 // // let x = get!(i32); // 1行の i32 の入力を受け取る // let x = get!(i32;2); // 2行の i32 の入力を受け取る // // tuple // let x = get!(i32,i32,i32); // (i32, i32, i32 )のタプルを受け取る // let x = get!(i32,i32,i32;2); // 2行 (i32, i32, i32 )のタプルを受け取る macro_rules! get { ($t:ty) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.trim().parse::<$t>().unwrap() } }; ($($t:ty),*) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( $(iter.next().unwrap().parse::<$t>().unwrap(),)* ) } }; ($t:ty; $n:expr) => { (0..$n).map(|_| get!($t) ).collect::>() }; ($($t:ty),*; $n:expr) => { (0..$n).map(|_| get!($($t),*) ).collect::>() }; ($t:ty ;;) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.split_whitespace() .map(|t| t.parse::<$t>().unwrap()) .collect::>() } }; ($t:ty ;; $n:expr) => { (0..$n).map(|_| get!($t ;;)).collect::>() }; } fn read_input() -> Option> { let n = get!(i32); if n < 0 { return None; } let mut enemies = vec![]; for _ in 0..n { enemies.push(get!(u32,u32,usize)); } Some(enemies) } #[derive (Clone, Copy, Debug)] struct Enemy { hp: u32, pw: u32, y: usize, } struct EnemyPool { pool: Vec>, } impl EnemyPool { fn new() -> EnemyPool { EnemyPool { pool: vec![VecDeque::new(); X] } } fn add(&mut self, enemy: &(u32, u32, usize)) { self.pool[enemy.2].push_back(Enemy { hp: enemy.0, pw: enemy.1, y: Y - 1 }); } fn step(&mut self) { for i in 0..self.pool.len() { if let Some(f) = self.pool[i].front() { if f.y == 0 { self.pool[i].pop_front(); } } for j in 0..self.pool[i].len() { self.pool[i][j].y -= 1; } } } fn get_first(&self, x: usize) -> Option<&Enemy> { return self.pool[x].front(); } } fn main() { let mut iter = 0; let mut pool = EnemyPool::new(); let mut x = 12; while let Some(enemies) = read_input() { pool.step(); for e in enemies { pool.add(&e); } if let Some(e) = pool.get_first(x) { if e.y == 0 { break; } } // 移動 println!("S"); // 攻撃 iter += 1; std::io::stdout().flush().unwrap(); if iter >= 1000 { break; } } } pub trait SetMinMax { fn setmin(&mut self, v: Self) -> bool; fn setmax(&mut self, v: Self) -> bool; } impl SetMinMax for T where T: PartialOrd { fn setmin(&mut self, v: T) -> bool { *self > v && { *self = v; true } } fn setmax(&mut self, v: T) -> bool { *self < v && { *self = v; true } } }