結果

問題 No.430 文字列検索
ユーザー kurenai3110kurenai3110
提出日時 2016-10-02 23:53:21
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,965 ms / 2,000 ms
コード長 660 bytes
コンパイル時間 717 ms
コンパイル使用メモリ 68,576 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 10:58:37
合計ジャッジ時間 9,899 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 26 ms
6,944 KB
testcase_02 AC 1,965 ms
6,940 KB
testcase_03 AC 1,004 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 632 ms
6,940 KB
testcase_12 AC 626 ms
6,944 KB
testcase_13 AC 618 ms
6,944 KB
testcase_14 AC 902 ms
6,940 KB
testcase_15 AC 1,208 ms
6,944 KB
testcase_16 AC 909 ms
6,940 KB
testcase_17 AC 886 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
using namespace std;

int main()
{
	string s;
	cin >> s;
	int m; cin >> m;
	int ans = 0;
	vector<int> alp[26];
	for (int i = 0; i < s.size(); i++)alp[s[i] - 'A'].push_back(i);

	for (int i = 0; i < m; i++) {
		string target; cin >> target;
		if (target[0] < 65 || 90 < target[0])continue;
		for (int i = 0; i < alp[target[0] - 'A'].size(); i++) {
			for (int j = 0; j < target.size(); j++) {
				if (target[j] < 65 || 90 < target[j])break;;
				if (s[alp[target[0] - 'A'][i] + j] != target[j])break;
				if (j == target.size() - 1)ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}
0