結果

問題 No.430 文字列検索
ユーザー keymoonkeymoon
提出日時 2019-04-19 14:12:55
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 350 ms / 2,000 ms
コード長 1,192 bytes
コンパイル時間 1,043 ms
コンパイル使用メモリ 109,244 KB
実行使用メモリ 67,096 KB
最終ジャッジ日時 2023-10-23 17:32:33
合計ジャッジ時間 4,845 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
24,100 KB
testcase_01 AC 349 ms
67,096 KB
testcase_02 AC 184 ms
28,164 KB
testcase_03 AC 182 ms
28,164 KB
testcase_04 AC 26 ms
24,100 KB
testcase_05 AC 26 ms
24,100 KB
testcase_06 AC 26 ms
24,036 KB
testcase_07 AC 26 ms
24,100 KB
testcase_08 AC 350 ms
67,096 KB
testcase_09 AC 27 ms
24,100 KB
testcase_10 AC 48 ms
28,408 KB
testcase_11 AC 247 ms
33,952 KB
testcase_12 AC 249 ms
33,952 KB
testcase_13 AC 251 ms
33,968 KB
testcase_14 AC 232 ms
31,116 KB
testcase_15 AC 219 ms
30,400 KB
testcase_16 AC 189 ms
28,176 KB
testcase_17 AC 186 ms
28,164 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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