結果

問題 No.430 文字列検索
ユーザー plasma_eplasma_e
提出日時 2019-01-20 17:31:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 734 bytes
コンパイル時間 2,339 ms
コンパイル使用メモリ 100,024 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-11 21:02:47
合計ジャッジ時間 11,991 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 35 ms
4,352 KB
testcase_02 TLE -
testcase_03 AC 1,153 ms
4,352 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 3 ms
4,352 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 759 ms
4,352 KB
testcase_12 AC 760 ms
4,352 KB
testcase_13 AC 758 ms
4,348 KB
testcase_14 AC 1,079 ms
4,352 KB
testcase_15 AC 1,354 ms
4,360 KB
testcase_16 AC 1,054 ms
4,348 KB
testcase_17 AC 1,001 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
#include<string>

int main()
{
	std::string str;
	std::cin >> str;
	auto N = str.size();
	std::vector<std::size_t> start[26];
	for (std::size_t i = 0; i < N; ++i)
	{
		start[str[i] - 'A'].emplace_back(i);
	}
	int M;
	std::cin >> M;
	int count = 0;
	for (int i = 0; i < M; ++i)
	{
		std::string C;
		std::cin >> C;
		for (auto s : start[C[0] - 'A'])
		{
			if (s + C.size() <= N)
			{
				++count;
				for (std::size_t k = 1; k < C.size() && s + k < N; ++k)
				{
					if (C[k] != str[k + s])
					{
						--count;
						break;
					}
				}
			}
		}
	}
	std::cout << count << std::endl;
}
0