結果
| 問題 | 
                            No.1534 おなかがいたい
                             | 
                    
| コンテスト | |
| ユーザー | 
                             umezo
                         | 
                    
| 提出日時 | 2021-06-06 18:08:18 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 11 ms / 2,000 ms | 
| コード長 | 493 bytes | 
| コンパイル時間 | 3,067 ms | 
| コンパイル使用メモリ | 192,752 KB | 
| 最終ジャッジ日時 | 2025-01-22 03:57:50 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 19 | 
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  string s;
  cin>>s;
  
  int n=s.size();
  int cnt=0;
  bool b=false;
  rep(i,n-3){
    if(s.substr(i,3)=="pon") cnt++;
    if(s.substr(i,4)=="pain"){
      b=true;
      break;
    }
  }
  if(b==false || cnt<2) cout<<-1<<endl;
  else cout<<cnt-1<<endl;
  
  return 0;
}
            
            
            
        
            
umezo