結果
問題 |
No.430 文字列検索
|
ユーザー |
![]() |
提出日時 | 2016-10-03 00:11:57 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,411 bytes |
コンパイル時間 | 1,541 ms |
コンパイル使用メモリ | 106,368 KB |
実行使用メモリ | 22,912 KB |
最終ジャッジ日時 | 2024-11-10 00:06:21 |
合計ジャッジ時間 | 4,468 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 4 |
other | AC * 2 TLE * 1 -- * 11 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; class Program { static int ReadInt() { return int.Parse(Console.ReadLine()); } static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); } static string[] ReadStrings() { return Console.ReadLine().Split(); } static int Calc(string s, List<string> xs) { var ss = new List<int>[26]; for (int i = 0; i < ss.Length; i++) ss[i] = new List<int>(); for (int i = 0; i < s.Length; i++) { ss[s[i] - 'A'].Add(i); } int ans = 0; for (int i = 0; i < xs.Count; i++) { var t = xs[i]; foreach (var p in ss[t[0] - 'A']) { bool ok = true; for (int j = 0; j < t.Length; j++) { if (p + j < s.Length && s[p + j] == t[j]) { // ok } else { ok = false; break; } } if (ok) ans++; } } return ans; } static void Main() { var s = Console.ReadLine(); int m = ReadInt(); var xs = new List<string>(); for (int i = 0; i < m; i++) xs.Add(Console.ReadLine()); var ans = Calc(s, xs); Console.WriteLine(ans); } }