結果

問題 No.430 文字列検索
ユーザー ebicochinealebicochineal
提出日時 2016-10-22 01:34:37
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 461 bytes
コンパイル時間 870 ms
コンパイル使用メモリ 55,772 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-03 04:46:36
合計ジャッジ時間 13,990 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 197 ms
5,376 KB
testcase_02 TLE -
testcase_03 AC 1,094 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 732 ms
5,376 KB
testcase_12 AC 729 ms
5,376 KB
testcase_13 AC 735 ms
5,376 KB
testcase_14 AC 1,307 ms
5,376 KB
testcase_15 AC 1,550 ms
5,376 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