結果

問題 No.430 文字列検索
ユーザー keymoon
提出日時 2019-04-19 14:12:55
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 299 ms / 2,000 ms
コード長 1,192 bytes
コンパイル時間 867 ms
コンパイル使用メモリ 104,576 KB
実行使用メモリ 59,964 KB
最終ジャッジ日時 2024-11-10 00:23:40
合計ジャッジ時間 4,533 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 14
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        Dictionary<string, int> dict = new Dictionary<string, int>();
        string s = Console.ReadLine();
        for (int i = 0; i < s.Length; i++)
        {
            for (int j = 1; j <= 10 && i + j <= s.Length; j++)
            {
                var key = s.Substring(i, j);
                if (!dict.ContainsKey(key)) dict.Add(key, 0);
                dict[s.Substring(i, j)]++;
            }
        }
        int m = int.Parse(Console.ReadLine());
        long res = 0;
        for (int i = 0; i < m; i++)
        {
            var key = Console.ReadLine();
            if (!dict.ContainsKey(key)) continue;
            res += dict[key];
        }
        Console.WriteLine(res);
    }
}
0