結果
問題 | No.430 文字列検索 |
ユーザー | 14番 |
提出日時 | 2016-11-08 02:43:00 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 222 ms / 2,000 ms |
コード長 | 2,052 bytes |
コンパイル時間 | 2,256 ms |
コンパイル使用メモリ | 108,880 KB |
実行使用メモリ | 28,252 KB |
最終ジャッジ日時 | 2023-08-16 14:48:10 |
合計ジャッジ時間 | 4,780 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 60 ms
19,340 KB |
testcase_01 | AC | 222 ms
26,120 KB |
testcase_02 | AC | 95 ms
28,172 KB |
testcase_03 | AC | 84 ms
26,120 KB |
testcase_04 | AC | 67 ms
21,580 KB |
testcase_05 | AC | 62 ms
23,500 KB |
testcase_06 | AC | 67 ms
19,700 KB |
testcase_07 | AC | 66 ms
21,616 KB |
testcase_08 | AC | 85 ms
27,744 KB |
testcase_09 | AC | 69 ms
21,840 KB |
testcase_10 | AC | 75 ms
25,872 KB |
testcase_11 | AC | 112 ms
26,116 KB |
testcase_12 | AC | 96 ms
26,224 KB |
testcase_13 | AC | 96 ms
26,172 KB |
testcase_14 | AC | 89 ms
26,348 KB |
testcase_15 | AC | 93 ms
28,252 KB |
testcase_16 | AC | 96 ms
26,144 KB |
testcase_17 | AC | 97 ms
24,148 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Text; using System.Linq; using System.Collections.Generic; public class Program { public void Proc() { Reader.IsDebug = false; string text = Reader.ReadLine(); long ans = 0; int wordCount = int.Parse(Reader.ReadLine()); Dictionary<char, Dictionary<int, Dictionary<string, bool>>> dic = new Dictionary<char, Dictionary<int, Dictionary<string, bool>>>(); for(int i=0; i<wordCount; i++) { string wrd = Reader.ReadLine(); if(!dic.ContainsKey(wrd[0])) { dic.Add(wrd[0], new Dictionary<int, Dictionary<string, bool>>()); } if(!dic[wrd[0]].ContainsKey(wrd.Length)) { dic[wrd[0]].Add(wrd.Length, new Dictionary<string, bool>()); } dic[wrd[0]][wrd.Length].Add(wrd, true); } for(int i=0; i<text.Length; i++) { if(!dic.ContainsKey(text[i])) { continue; } foreach(int len in dic[text[i]].Keys.OrderBy(a=>a)) { if(len > text.Length - i) { break; } string target = text.Substring(i, len); if(dic[text[i]][len].ContainsKey(target)) { ans++; } } } Console.WriteLine(ans); } public class Reader { public static bool IsDebug = true; private static System.IO.StringReader SReader; private static string InitText = @" ABAACABCAACBABABACBBAC 7 A C AA ABB ABA BA CBBAC "; public static string ReadLine() { if(IsDebug) { if(SReader == null) { SReader = new System.IO.StringReader(InitText.Trim()); } return SReader.ReadLine(); } else { return Console.ReadLine(); } } } public static void Main(string[] args) { Program prg = new Program(); prg.Proc(); } }