結果

問題 No.1534 おなかがいたい
ユーザー ゅゅ
提出日時 2021-03-13 16:15:33
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 572 bytes
コンパイル時間 1,584 ms
コンパイル使用メモリ 167,312 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-20 14:05:19
合計ジャッジ時間 2,496 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    
    string s;
    cin >> s;
    int pain = 0, count = -1;
    
    for (int i = 0; i+2 < s.size(); i++){
        if ( s[i] == 'p' && s[i+1] == 'o' && s[i+2] == 'n'){
            count++;
        }
        if ( i >= 1 ){
            if ( s[i-1] == 'p' && s[i] == 'a' && s[i+1] == 'i' && s[i+2] == 'n' ){
                pain++;
                break;
            }
        }
    }
    
    if ( count >= 1 && pain != 0 ){
        cout << count << endl;
    }
    else {
        cout << -1 << endl;
    }
    
}
0