結果

問題 No.430 文字列検索
ユーザー phsplsphspls
提出日時 2022-12-02 00:02:32
言語 Rust
(1.77.0)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 815 bytes
コンパイル時間 1,743 ms
コンパイル使用メモリ 180,012 KB
実行使用メモリ 34,756 KB
最終ジャッジ日時 2024-04-17 11:17:47
合計ジャッジ時間 3,426 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 240 ms
34,756 KB
testcase_02 AC 28 ms
5,376 KB
testcase_03 AC 29 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 247 ms
34,472 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 12 ms
6,004 KB
testcase_11 AC 53 ms
10,260 KB
testcase_12 AC 53 ms
10,264 KB
testcase_13 AC 55 ms
10,380 KB
testcase_14 AC 41 ms
6,320 KB
testcase_15 AC 34 ms
5,376 KB
testcase_16 AC 29 ms
5,376 KB
testcase_17 AC 29 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::HashMap;


fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let s = s.trim();
    let mut m = String::new();
    std::io::stdin().read_line(&mut m).ok();
    let m: usize = m.trim().parse().unwrap();
    let words = (0..m).map(|_| {
            let mut temp = String::new();
            std::io::stdin().read_line(&mut temp).ok();
            let temp = temp.trim();
            temp.to_string()
        })
        .collect::<Vec<_>>();

    let mut mapping = HashMap::new();
    for i in 1..=10 {
        if i > s.len() { break; }
        for j in 0..s.len()-i+1 {
            *mapping.entry(s[j..j+i].to_string()).or_insert(0usize) += 1;
        }
    }
    println!("{}", words.iter().map(|v| *mapping.get(v).unwrap_or(&0usize)).sum::<usize>());
}
0