#![allow(non_snake_case)] #![allow(unused_imports)] #![allow(unused_macros)] #![allow(clippy::comparison_chain)] #![allow(clippy::nonminimal_bool)] #![allow(clippy::neg_multiply)] #![allow(clippy::type_complexity)] #![allow(clippy::needless_range_loop)] #![allow(dead_code)] use std::{ cmp::Reverse, collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque}, }; mod rnd { static mut S: usize = 0; static MAX: usize = 1e9 as usize; #[inline] pub fn init(seed: usize) { unsafe { if seed == 0 { let t = std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) .unwrap() .as_secs() as usize; S = t } else { S = seed; } } } #[inline] pub fn gen() -> usize { unsafe { if S == 0 { init(0); } S ^= S << 7; S ^= S >> 9; S } } #[inline] pub fn gen_range(a: usize, b: usize) -> usize { gen() % (b - a) + a } #[inline] pub fn gen_bool() -> bool { gen() & 1 == 1 } #[inline] pub fn gen_range_isize(a: usize) -> isize { let mut x = (gen() % a) as isize; if gen_bool() { x *= -1; } x } #[inline] pub fn gen_range_neg_wrapping(a: usize) -> usize { let mut x = gen() % a; if gen_bool() { x = x.wrapping_neg(); } x } #[inline] pub fn gen_float() -> f64 { ((gen() % MAX) as f64) / MAX as f64 } } #[derive(Debug, Clone)] struct TimeKeeper { start_time: std::time::Instant, time_threshold: f64, } impl TimeKeeper { fn new(time_threshold: f64) -> Self { TimeKeeper { start_time: std::time::Instant::now(), time_threshold, } } #[inline] fn isTimeOver(&self) -> bool { let elapsed_time = self.start_time.elapsed().as_nanos() as f64 * 1e-9; #[cfg(feature = "local")] { elapsed_time * 1.5 >= self.time_threshold } #[cfg(not(feature = "local"))] { elapsed_time >= self.time_threshold } } #[inline] fn get_time(&self) -> f64 { let elapsed_time = self.start_time.elapsed().as_nanos() as f64 * 1e-9; #[cfg(feature = "local")] { elapsed_time * 1.5 } #[cfg(not(feature = "local"))] { elapsed_time } } } const H: usize = 60; const W: usize = 25; const TURN: usize = 1000; #[derive(Debug, Clone)] struct State { pos: usize, level: usize, enemy: [[(usize, usize); W]; H], turn: usize, } impl State { fn new() -> Self { State { pos: 12, level: 1, enemy: [[(0, 0); W]; H], turn: 0, } } fn update_enemy(&mut self, HPX: Vec<(usize, usize, usize)>) { for i in 1..H { self.enemy[i - 1] = self.enemy[i]; } let mut new_enemy = [(0, 0); W]; for (h, p, x) in HPX { new_enemy[x] = (h, p); } self.enemy[H - 1] = new_enemy; } fn move_me(&mut self) -> usize { let r_enemy = self.enemy[0][(self.pos + 1) % W]; let l_enemy = self.enemy[0][(W + self.pos - 1) % W]; if r_enemy == (0, 0) { self.pos = (self.pos + 1) % W; return 2; } if l_enemy == (0, 0) { self.pos = (W + self.pos - 1) % W; return 1; } return 0; } fn is_done(&self) -> bool { self.turn == TURN } } #[derive(Default)] struct Solver {} impl Solver { fn solve(&mut self) { let mut state = State::new(); while !state.is_done() { let N: isize = read(); if N == -1 { return; } state.turn += 1; let mut HPX = vec![]; for _ in 0..N { let v: Vec = read_vec(); let h = v[0]; let p = v[1]; let x = v[2]; HPX.push((h, p, x)); } state.update_enemy(HPX); let c = state.move_me(); if c == 0 { println!("S"); } else if c == 1 { println!("L"); } else { println!("R"); } } } } fn main() { std::thread::Builder::new() .stack_size(128 * 1024 * 1024) .spawn(|| Solver::default().solve()) .unwrap() .join() .unwrap(); } fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec() -> Vec { read::() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() }