結果

問題 No.430 文字列検索
ユーザー ebicochinealebicochineal
提出日時 2016-10-22 01:34:37
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 461 bytes
コンパイル時間 912 ms
コンパイル使用メモリ 52,652 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-15 17:54:37
合計ジャッジ時間 14,978 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 216 ms
4,380 KB
testcase_02 TLE -
testcase_03 AC 1,207 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 832 ms
4,384 KB
testcase_12 AC 834 ms
4,380 KB
testcase_13 AC 828 ms
4,380 KB
testcase_14 AC 1,385 ms
4,380 KB
testcase_15 AC 1,597 ms
4,384 KB
testcase_16 TLE -
testcase_17 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int f(string s, string t) {
    int p = 0, cnt = 0;
    while (1) {
        p = s.find(t);
        if (p >= 0) {
            ++cnt;
            s.erase(0, p+1);
        } else {
            break;
        }
    }
    return cnt;
}

int main() {
    string s, t; int ans = 0, m;
    cin >> s >> m;
    for (int i = 0; i < m; ++i) {
        cin >> t;
        ans += f(s, t);
    }
    cout << ans << endl;
    return 0;
}
0