結果

問題 No.1159 Sashiming String
ユーザー rana
提出日時 2021-09-10 01:37:19
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 596 bytes
コンパイル時間 781 ms
コンパイル使用メモリ 80,252 KB
最終ジャッジ日時 2025-01-24 09:06:31
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main(void) {
    string s;
    cin >> s;

    vector<int> idxs;
    for (int i = 0; i < s.size()-2; ++i) {
        if (s.substr(i, 3) == "ing") idxs.push_back(i);
    }

    long long ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'S') {
            auto it = lower_bound(idxs.begin(), idxs.end(), i);
            if (it == idxs.end()) continue;

            int idx = it - idxs.begin();
            ans += (idxs.size() - idx);
        }
    }

    cout << ans << endl;
}
0