結果

問題 No.430 文字列検索
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2016-10-02 23:20:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 268 ms / 2,000 ms
コード長 494 bytes
コンパイル時間 1,818 ms
コンパイル使用メモリ 175,044 KB
実行使用メモリ 32,528 KB
最終ジャッジ日時 2023-08-15 17:25:13
合計ジャッジ時間 4,174 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 260 ms
32,528 KB
testcase_02 AC 29 ms
4,376 KB
testcase_03 AC 32 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 268 ms
32,200 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 19 ms
6,464 KB
testcase_11 AC 129 ms
8,472 KB
testcase_12 AC 127 ms
8,620 KB
testcase_13 AC 132 ms
8,636 KB
testcase_14 AC 109 ms
6,652 KB
testcase_15 AC 90 ms
5,488 KB
testcase_16 AC 48 ms
4,376 KB
testcase_17 AC 38 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)


string S;
int M;
string C[5010];
map<string, int> cnt;
//-----------------------------------------------------------------
int main() {
	cin >> S >> M;
	rep(i, 0, M) cin >> C[i];

	int N = S.length();
	rep(i, 0, N) {
		string s = "";

		rep(len, 1, 11) {
			int j = i - len + 1;
			if (j < 0) break;
			s = S[j] + s;
			cnt[s]++;
		}
	}

	int ans = 0;
	rep(i, 0, M) ans += cnt[C[i]];
	cout << ans << endl;
}
0