結果
| 問題 | 
                            No.1534 おなかがいたい
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-06-06 18:20:48 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 11 ms / 2,000 ms | 
| コード長 | 364 bytes | 
| コンパイル時間 | 1,632 ms | 
| コンパイル使用メモリ | 167,076 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-23 02:41:54 | 
| 合計ジャッジ時間 | 2,746 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 19 | 
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(){
	string s;
	cin>>s;
	int n=s.size();
	int cnt=0;
	int r=s.find("pain");
	if(r!=n){
		for(int i=r-1; i>=0; i--){
			if(s.substr(i, 3)=="pon") cnt++;
		}
	}
	if(cnt<2) cnt=0;
	cout<<(cnt-1)<<endl;
	return 0;
}