結果

問題 No.430 文字列検索
ユーザー square1001square1001
提出日時 2016-11-05 13:56:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 217 ms / 2,000 ms
コード長 420 bytes
コンパイル時間 1,760 ms
コンパイル使用メモリ 175,972 KB
実行使用メモリ 21,540 KB
最終ジャッジ日時 2023-08-16 13:51:52
合計ジャッジ時間 4,541 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 217 ms
19,676 KB
testcase_02 AC 123 ms
21,540 KB
testcase_03 AC 125 ms
20,248 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 212 ms
19,884 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 20 ms
5,176 KB
testcase_11 AC 185 ms
20,488 KB
testcase_12 AC 181 ms
20,292 KB
testcase_13 AC 181 ms
19,716 KB
testcase_14 AC 173 ms
20,976 KB
testcase_15 AC 164 ms
19,852 KB
testcase_16 AC 131 ms
21,104 KB
testcase_17 AC 123 ms
21,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
string s, t; int Q;
int main() {
	cin >> s;
	vector<string> b;
	for(int i = 1; i <= 10; i++) {
		for(int j = i; j <= s.size(); j++) {
			b.push_back(s.substr(j - i, i));
		}
	}
	sort(b.begin(), b.end());
	int ret = 0;
	cin >> Q;
	while(Q--) {
		cin >> t;
		ret += upper_bound(b.begin(), b.end(), t) - lower_bound(b.begin(), b.end(), t);
	}
	cout << ret << endl;
	return 0;
}
0