結果

問題 No.8119 間に合いませんでした><;
ユーザー ArcAki
提出日時 2025-04-03 08:14:31
言語 Rust
(1.83.0 + proconio)
結果
TLE  
実行時間 -
コード長 7,709 bytes
コンパイル時間 15,245 ms
コンパイル使用メモリ 404,748 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-04-03 08:14:59
合計ジャッジ時間 18,927 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 23 TLE * 2 -- * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#[allow(unused_imports)]
use std::{
    collections::{*},
    cmp::{Reverse, Ordering, Ord, PartialOrd, PartialEq},
    mem::{swap},
    time::Instant,
    fs::File,
    io::{self, stdin, read_to_string},
    hash::Hash,
};
#[allow(unused_imports)]
use crate::input::{Usize1, Chars};
#[allow(unused_variables)]
const MOD: i64 = 998244353;

// qryxipさんのコードをお借りしています!!ありがとうございます!!

fn main() {
    let __fastout_stdout = ::std::io::stdout();
    let __fastout_stdout = &mut ::std::io::BufWriter::new(__fastout_stdout.lock());
    #[allow(unused_macros)]
    macro_rules ! print
    {($ ($ tt : tt) *) =>{{
        use std :: io :: Write as _ ; :: std :: write !
        (__fastout_stdout, $ ($ tt) *) . unwrap () ;}};}
    #[allow(unused_macros)]
    macro_rules ! println
    {($ ($ tt : tt) *) =>{{
        use std :: io :: Write as _ ; :: std :: writeln !
        (__fastout_stdout, $ ($ tt) *) . unwrap ();}} ;}

    let __fastout_res = {
        // 本体コードはここから

        input! {
            n: usize,
            s: Chars,
        }
        if n%10!=0{
            println!("0"); return;
        }
        let k = n/10;
        let mut dp = vec![0; k+1];
        dp[0] = 1;
        for i in 0..k{
            let p = i*10;
            for j in 1..=k-i{
                if s[p+2*j]=='o'&&s[p+5*j]=='o'&&s[p+10*j]=='o'{
                    dp[i+j] = (dp[i+j]+dp[i])%MOD;
                }
            }
        }
        println!("{}", dp[k]);

        // 本体コードここまで
    };

    <::std::io::BufWriter<_> as ::std::io::Write>::flush(__fastout_stdout).unwrap();
    __fastout_res
}

#[allow(unused)]
pub mod input {
    pub use crate::{input, input_inner, read, readable};
    use std::{
        cell::RefCell,
        fmt::Debug,
        io::{self, BufRead, Read},
        rc::Rc,
        str::{FromStr, SplitWhitespace},
    };

    #[macro_export]
    macro_rules! input {
        (from $scanner:ident; $($tt:tt)*) => {
            $crate::input::input_inner!(@scanner($scanner), @tts($($tt)*))
        };
        ($($tt:tt)*) => {
            let __scanner = $crate::input::DEFAULT_SCANNER.with(|__scanner| __scanner.clone());
            let mut __scanner_ref = __scanner.borrow_mut();
            if let $crate::input::Scanner::Uninited = *__scanner_ref {
                *__scanner_ref = $crate::input::Scanner::stdin_auto().unwrap();
            }
            $crate::input::input_inner!(@scanner(__scanner_ref), @tts($($tt)*));
            ::std::mem::drop(__scanner_ref);
            ::std::mem::drop(__scanner);
        };
    }

    #[macro_export]
    macro_rules! input_inner {
        (@scanner($scanner:ident), @tts()) => {};
        (@scanner($scanner:ident), @tts(mut $single_tt_pat:tt : $readable:tt)) => {
            let mut $single_tt_pat = $crate::input::read!(from $scanner { $readable });
        };
        (@scanner($scanner:ident), @tts($single_tt_pat:tt : $readable:tt)) => {
            let $single_tt_pat = $crate::input::read!(from $scanner { $readable });
        };
        (@scanner($scanner:ident), @tts(mut $single_tt_pat:tt : $readable:tt, $($rest:tt)*)) => {
            $crate::input::input_inner!(@scanner($scanner), @tts(mut $single_tt_pat: $readable));
            $crate::input::input_inner!(@scanner($scanner), @tts($($rest)*));
        };
        (@scanner($scanner:ident), @tts($single_tt_pat:tt : $readable:tt, $($rest:tt)*)) => {
            $crate::input::input_inner!(@scanner($scanner), @tts($single_tt_pat: $readable));
            $crate::input::input_inner!(@scanner($scanner), @tts($($rest)*));
        };
    }

    #[macro_export]
    macro_rules! read {
        (from $scanner:ident { [$tt:tt] }) => {
            $crate::input::read!(from $scanner { [$tt; $crate::read!(from $scanner { usize })] })
        };
        (from $scanner:ident  { [$tt:tt; $n:expr] }) => {
            (0..$n).map(|_| $crate::input::read!(from $scanner { $tt })).collect::<Vec<_>>()
        };
        (from $scanner:ident { ($($tt:tt),+) }) => {
            ($($crate::read!(from $scanner { $tt })),*)
        };
        (from $scanner:ident { $ty:ty }) => {
            <$ty as $crate::input::Readable>::read_from_scanner(&mut $scanner)
        };
    }

    #[macro_export]
    macro_rules! readable {
        ($name:ident; |$scanner:ident| { $($body:tt)* }) => {
            $crate::input::readable!($name; |$scanner| -> () { $($body)* });
        };
        ($name:ident; |$scanner:ident| $expr:expr) => {
            $crate::input::readable!($name; |$scanner| -> () { $expr });
        };
        ($name:ident; |$scanner:ident| -> $output:ty { $($body:tt)* }) => {
            enum $name {}

            impl $crate::input::Readable for $name {
                type Output = $output;

                fn read_from_scanner(mut $scanner: &mut $crate::input::Scanner) -> $output {
                    $($body)*
                }
            }
        };
    }

    pub enum Scanner {
        Uninited,
        Once {
            words: SplitWhitespace<'static>,
        },
        Lines {
            rdr: Box<dyn BufRead>,
            words: SplitWhitespace<'static>,
        },
    }

    impl Scanner {
        pub fn stdin_auto() -> io::Result<Self> {
            if cfg!(debug_assertions) {
                Ok(Self::lines(Box::leak(Box::new(io::stdin())).lock()))
            } else {
                Self::once(io::stdin())
            }
        }

        pub fn once<R: Read>(mut rdr: R) -> io::Result<Self> {
            let mut buf = String::with_capacity(1024);
            rdr.read_to_string(&mut buf)?;
            let words = Box::leak(buf.into_boxed_str()).split_whitespace();
            Ok(Self::Once { words })
        }

        pub fn lines<R: BufRead + 'static>(rdr: R) -> Self {
            Self::Lines {
                rdr: Box::new(rdr),
                words: "".split_whitespace(),
            }
        }

        pub fn parse_next_unwrap<T: FromStr>(&mut self) -> T
        where
            T::Err: Debug,
        {
            match self {
                Self::Uninited => None,
                Self::Once { words } => words.next(),
                Self::Lines { rdr, words } => words.next().or_else(|| {
                    let mut line = "".to_owned();
                    rdr.read_line(&mut line).unwrap();
                    *words = Box::leak(line.into_boxed_str()).split_whitespace();
                    words.next()
                }),
            }
                .expect("reached EOF")
                .parse()
                .unwrap()
        }
    }

    thread_local! {
        pub static DEFAULT_SCANNER: Rc<RefCell<Scanner>> = Rc::new(RefCell::new(Scanner::Uninited));
    }

    pub trait Readable {
        type Output;

        fn read_from_scanner(scanner: &mut Scanner) -> Self::Output;
    }

    impl<T: FromStr> Readable for T
    where
        T::Err: Debug,
    {
        type Output = Self;

        fn read_from_scanner(scanner: &mut Scanner) -> Self {
            scanner.parse_next_unwrap()
        }
    }

    pub enum Usize1 {}
    pub enum Chars {}
    impl Readable for Usize1 {
        type Output = usize;

        fn read_from_scanner(scanner: &mut Scanner) -> Self::Output {
            let val: usize = scanner.parse_next_unwrap();
            if val == 0 {
                panic!("Usize1-0-parse-error");
            }
            val - 1
        }
    }

    impl Readable for Chars {
        type Output = Vec<char>;

        fn read_from_scanner(scanner: &mut Scanner) -> Self::Output {
            let val: String = scanner.parse_next_unwrap();
            val.chars().collect()
        }
    }
}
0