結果

問題 No.430 文字列検索
ユーザー ebicochineal
提出日時 2016-10-22 01:34:37
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1,859 ms / 2,000 ms
コード長 461 bytes
コンパイル時間 784 ms
コンパイル使用メモリ 55,900 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-10 00:11:31
合計ジャッジ時間 12,745 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

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