結果

問題 No.5017 Tool-assisted Shooting
ユーザー tipstar0125
提出日時 2023-07-16 14:30:16
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 7,789 bytes
コンパイル時間 1,277 ms
コンパイル使用メモリ 158,724 KB
実行使用メモリ 24,408 KB
スコア 1,873
平均クエリ数 78.46
最終ジャッジ日時 2023-07-16 14:30:25
合計ジャッジ時間 8,446 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

#![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,
    enemy: [[(usize, usize); W]; H],
    turn: usize,
}

impl State {
    fn new() -> Self {
        State {
            pos: 12,
            enemy: [[(0, 0); W]; H],
            turn: 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() {
            // input! {
            //     N: isize
            // }
            let N: isize = read();
            if N == -1 {
                return;
            }
            state.turn += 1;
            // input! {
            //     HPX: [(usize, usize, usize); N]
            // }
            let mut HPX = vec![];
            for _ in 0..N {
                let v: Vec<usize> = read_vec();
                let h = v[0];
                let p = v[1];
                let x = v[2];
                HPX.push((h, p, x));
            }

            // println!("S");
            let r = rnd::gen_range(0, 3);
            if r == 0 {
                println!("S");
            } else if r == 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: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
// #[macro_export]
// macro_rules! input {
//     () => {};
//     (mut $var:ident: $t:tt, $($rest:tt)*) => {
//         let mut $var = __input_inner!($t);
//         input!($($rest)*)
//     };
//     ($var:ident: $t:tt, $($rest:tt)*) => {
//         let $var = __input_inner!($t);
//         input!($($rest)*)
//     };
//     (mut $var:ident: $t:tt) => {
//         let mut $var = __input_inner!($t);
//     };
//     ($var:ident: $t:tt) => {
//         let $var = __input_inner!($t);
//     };
// }

// #[macro_export]
// macro_rules! __input_inner {
//     (($($t:tt),*)) => {
//         ($(__input_inner!($t)),*)
//     };
//     ([$t:tt; $n:expr]) => {
//         (0..$n).map(|_| __input_inner!($t)).collect::<Vec<_>>()
//     };
//     ([$t:tt]) => {{
//         let n = __input_inner!(usize);
//         (0..n).map(|_| __input_inner!($t)).collect::<Vec<_>>()
//     }};
//     (chars) => {
//         __input_inner!(String).chars().collect::<Vec<_>>()
//     };
//     (bytes) => {
//         __input_inner!(String).into_bytes()
//     };
//     (usize1) => {
//         __input_inner!(usize) - 1
//     };
//     ($t:ty) => {
//         $crate::read::<$t>()
//     };
// }

// #[macro_export]
// macro_rules! println {
//     () => {
//         $crate::write(|w| {
//             use std::io::Write;
//             std::writeln!(w).unwrap()
//         })
//     };
//     ($($arg:tt)*) => {
//         $crate::write(|w| {
//             use std::io::Write;
//             std::writeln!(w, $($arg)*).unwrap()
//         })
//     };
// }

// #[macro_export]
// macro_rules! print {
//     ($($arg:tt)*) => {
//         $crate::write(|w| {
//             use std::io::Write;
//             std::write!(w, $($arg)*).unwrap()
//         })
//     };
// }

// #[macro_export]
// macro_rules! flush {
//     () => {
//         $crate::write(|w| {
//             use std::io::Write;
//             w.flush().unwrap()
//         })
//     };
// }

// pub fn read<T>() -> T
// where
//     T: std::str::FromStr,
//     T::Err: std::fmt::Debug,
// {
//     use std::cell::RefCell;
//     use std::io::*;

//     thread_local! {
//         pub static STDIN: RefCell<StdinLock<'static>> = RefCell::new(stdin().lock());
//     }

//     STDIN.with(|r| {
//         let mut r = r.borrow_mut();
//         let mut s = vec![];
//         loop {
//             let buf = r.fill_buf().unwrap();
//             if buf.is_empty() {
//                 break;
//             }
//             if let Some(i) = buf.iter().position(u8::is_ascii_whitespace) {
//                 s.extend_from_slice(&buf[..i]);
//                 r.consume(i + 1);
//                 if !s.is_empty() {
//                     break;
//                 }
//             } else {
//                 s.extend_from_slice(buf);
//                 let n = buf.len();
//                 r.consume(n);
//             }
//         }
//         std::str::from_utf8(&s).unwrap().parse().unwrap()
//     })
// }

// pub fn write<F>(f: F)
// where
//     F: FnOnce(&mut std::io::BufWriter<std::io::StdoutLock>),
// {
//     use std::cell::RefCell;
//     use std::io::*;

//     thread_local! {
//         pub static STDOUT: RefCell<BufWriter<StdoutLock<'static>>> =
//             RefCell::new(BufWriter::new(stdout().lock()));
//     }

//     STDOUT.with(|w| f(&mut w.borrow_mut()))
// }
0