Submission #19660042


Source Code Expand

Copy
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let n: usize = read_as_vec()[0];
    let mm = 1_000_000_007;
    let s = read_as_string().chars().collect::<Vec<char>>();
    let mut dp: Vec<usize> = vec![0; s.len() + 1];
    dp[0] = 1;
    let mut tv: Vec<Vec<char>> = vec![];
    for _ in 0..n {
        let t = read_as_string().chars().collect::<Vec<char>>();
        tv.push(t);
    }

    for i in 1..=s.len() {
        for t in &tv {
            if t.len() > i {
                continue;
            }
            let mut is_matched = true;
            for j in 0..t.len() {
                if t[j] != s[i - t.len() + j] {
                    is_matched = false;
                    break;
                }
            }
            if is_matched {
                dp[i] += dp[i - t.len()];
                dp[i] %= mm;
            }
        }
    }
    println!("{}", dp[s.len()]);
}

Submission Info

Submission Time
Task B - エターナルスタティックファイナル
User tatsuya0619
Language Rust (1.42.0)
Score 60
Code Size 1369 Byte
Status AC
Exec Time 12 ms
Memory 2216 KB

Compile Error

warning: unused import: `std::cmp`
 --> src/main.rs:1:5
  |
1 | use std::cmp;
  |     ^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

Judge Result

Set Name All
Score / Max Score 60 / 60
Status
AC × 108
Set Name Test Cases
All 00_sample00.txt, 00_sample01.txt, 00_sample02.txt, 00_sample03.txt, 00_sample04.txt, 01_random00.txt, 01_random01.txt, 01_random02.txt, 01_random03.txt, 01_random04.txt, 01_random05.txt, 01_random06.txt, 01_random07.txt, 01_random08.txt, 01_random09.txt, 01_random10.txt, 01_random11.txt, 01_random12.txt, 01_random13.txt, 01_random14.txt, 01_random15.txt, 01_random16.txt, 01_random17.txt, 01_random18.txt, 01_random19.txt, 01_random20.txt, 01_random21.txt, 01_random22.txt, 01_random23.txt, 01_random24.txt, 01_random25.txt, 01_random26.txt, 01_random27.txt, 01_random28.txt, 01_random29.txt, 01_random30.txt, 01_random31.txt, 01_random32.txt, 01_random33.txt, 01_random34.txt, 01_random35.txt, 01_random36.txt, 01_random37.txt, 01_random38.txt, 01_random39.txt, 01_random40.txt, 01_random41.txt, 01_random42.txt, 01_random43.txt, 01_random44.txt, 01_random45.txt, 01_random46.txt, 01_random47.txt, 01_random48.txt, 01_random49.txt, 01_random50.txt, 01_random51.txt, 01_random52.txt, 01_random53.txt, 01_random54.txt, 01_random55.txt, 01_random56.txt, 01_random57.txt, 01_random58.txt, 01_random59.txt, 01_random61.txt, 01_random62.txt, 01_random63.txt, 01_random64.txt, 01_random65.txt, 01_random66.txt, 01_random67.txt, 01_random68.txt, 01_random69.txt, 01_random70.txt, 01_random71.txt, 01_random72.txt, 01_random73.txt, 01_random74.txt, 01_random75.txt, 01_random76.txt, 01_random77.txt, 01_random78.txt, 01_random79.txt, 01_random80.txt, 01_random81.txt, 01_random82.txt, 01_random83.txt, 01_random84.txt, 01_random85.txt, 01_random86.txt, 01_random87.txt, 01_random88.txt, 01_random89.txt, 01_random90.txt, 01_random91.txt, 01_random92.txt, 01_random93.txt, 01_random94.txt, 01_random95.txt, 01_random96.txt, 01_random97.txt, 01_random98.txt, 01_random99.txt, 02_manual00.txt, 02_manual01.txt, 02_manual02.txt, 02_manual03.txt
Case Name Status Exec Time Memory
00_sample00.txt AC 6 ms 2096 KB
00_sample01.txt AC 1 ms 2032 KB
00_sample02.txt AC 1 ms 1976 KB
00_sample03.txt AC 1 ms 2060 KB
00_sample04.txt AC 2 ms 2064 KB
01_random00.txt AC 2 ms 2088 KB
01_random01.txt AC 2 ms 2148 KB
01_random02.txt AC 2 ms 2056 KB
01_random03.txt AC 2 ms 2088 KB
01_random04.txt AC 2 ms 1988 KB
01_random05.txt AC 2 ms 2108 KB
01_random06.txt AC 2 ms 2092 KB
01_random07.txt AC 2 ms 2028 KB
01_random08.txt AC 1 ms 2000 KB
01_random09.txt AC 2 ms 2024 KB
01_random10.txt AC 5 ms 1968 KB
01_random11.txt AC 2 ms 2076 KB
01_random12.txt AC 2 ms 2076 KB
01_random13.txt AC 1 ms 2032 KB
01_random14.txt AC 2 ms 2196 KB
01_random15.txt AC 1 ms 2036 KB
01_random16.txt AC 2 ms 2080 KB
01_random17.txt AC 2 ms 2036 KB
01_random18.txt AC 2 ms 2024 KB
01_random19.txt AC 2 ms 2056 KB
01_random20.txt AC 2 ms 2060 KB
01_random21.txt AC 2 ms 2196 KB
01_random22.txt AC 2 ms 2012 KB
01_random23.txt AC 2 ms 2112 KB
01_random24.txt AC 2 ms 2008 KB
01_random25.txt AC 1 ms 2148 KB
01_random26.txt AC 2 ms 1980 KB
01_random27.txt AC 2 ms 2092 KB
01_random28.txt AC 2 ms 2048 KB
01_random29.txt AC 2 ms 2004 KB
01_random30.txt AC 1 ms 2000 KB
01_random31.txt AC 3 ms 2080 KB
01_random32.txt AC 2 ms 2108 KB
01_random33.txt AC 2 ms 2060 KB
01_random34.txt AC 2 ms 2188 KB
01_random35.txt AC 2 ms 2128 KB
01_random36.txt AC 2 ms 2012 KB
01_random37.txt AC 1 ms 2028 KB
01_random38.txt AC 2 ms 2048 KB
01_random39.txt AC 5 ms 2116 KB
01_random40.txt AC 2 ms 2148 KB
01_random41.txt AC 2 ms 2020 KB
01_random42.txt AC 2 ms 2100 KB
01_random43.txt AC 2 ms 2064 KB
01_random44.txt AC 2 ms 2132 KB
01_random45.txt AC 2 ms 2112 KB
01_random46.txt AC 2 ms 2172 KB
01_random47.txt AC 2 ms 2076 KB
01_random48.txt AC 2 ms 2020 KB
01_random49.txt AC 2 ms 2008 KB
01_random50.txt AC 2 ms 2112 KB
01_random51.txt AC 3 ms 2120 KB
01_random52.txt AC 2 ms 2040 KB
01_random53.txt AC 2 ms 2100 KB
01_random54.txt AC 2 ms 2140 KB
01_random55.txt AC 2 ms 2080 KB
01_random56.txt AC 2 ms 2032 KB
01_random57.txt AC 2 ms 2096 KB
01_random58.txt AC 2 ms 1992 KB
01_random59.txt AC 2 ms 2004 KB
01_random61.txt AC 6 ms 2168 KB
01_random62.txt AC 2 ms 1976 KB
01_random63.txt AC 2 ms 2168 KB
01_random64.txt AC 2 ms 2028 KB
01_random65.txt AC 3 ms 2076 KB
01_random66.txt AC 2 ms 2216 KB
01_random67.txt AC 2 ms 2080 KB
01_random68.txt AC 2 ms 1952 KB
01_random69.txt AC 2 ms 2084 KB
01_random70.txt AC 2 ms 2084 KB
01_random71.txt AC 3 ms 2052 KB
01_random72.txt AC 2 ms 2104 KB
01_random73.txt AC 2 ms 2112 KB
01_random74.txt AC 2 ms 2104 KB
01_random75.txt AC 2 ms 1988 KB
01_random76.txt AC 2 ms 2036 KB
01_random77.txt AC 3 ms 2132 KB
01_random78.txt AC 2 ms 2024 KB
01_random79.txt AC 2 ms 2048 KB
01_random80.txt AC 2 ms 2192 KB
01_random81.txt AC 2 ms 2016 KB
01_random82.txt AC 2 ms 2184 KB
01_random83.txt AC 2 ms 2052 KB
01_random84.txt AC 2 ms 1980 KB
01_random85.txt AC 2 ms 1956 KB
01_random86.txt AC 2 ms 2036 KB
01_random87.txt AC 2 ms 2028 KB
01_random88.txt AC 2 ms 2052 KB
01_random89.txt AC 2 ms 2168 KB
01_random90.txt AC 2 ms 2112 KB
01_random91.txt AC 2 ms 2048 KB
01_random92.txt AC 2 ms 1928 KB
01_random93.txt AC 2 ms 2076 KB
01_random94.txt AC 2 ms 1956 KB
01_random95.txt AC 2 ms 2032 KB
01_random96.txt AC 2 ms 2100 KB
01_random97.txt AC 2 ms 2020 KB
01_random98.txt AC 3 ms 2160 KB
01_random99.txt AC 2 ms 2032 KB
02_manual00.txt AC 12 ms 1928 KB
02_manual01.txt AC 2 ms 1984 KB
02_manual02.txt AC 3 ms 2120 KB
02_manual03.txt AC 2 ms 1956 KB