結果

問題 No.1534 おなかがいたい
ユーザー れいん
提出日時 2025-06-04 20:34:11
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 586 bytes
コンパイル時間 3,481 ms
コンパイル使用メモリ 273,912 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-06-04 20:34:17
合計ジャッジ時間 5,171 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
    string S;
    cin >> S;
    int N = S.size();
    int pain = -1;
    for (int i = 0; i < N - 3; i++)
    {
        if (S.substr(i, 4) == "pain")
        {
            pain = i;
            break;
        }
    }
    if (pain == -1)
    {
        cout << -1;
        return 0;
    }
    int pon = 0;
    for (int i = 0; i < pain - 2; i++)
    {
        if (S.substr(i, 3) == "pon")
        {
            pon++;
        }
    }
    if (pon < 2)
    {
        cout << -1;
    }
    else
    {
        cout << pon - 1;
    }
}
0