結果

問題 No.1534 おなかがいたい
ユーザー okkuukenken
提出日時 2022-07-19 13:23:25
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 555 bytes
コンパイル時間 1,459 ms
コンパイル使用メモリ 132,244 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-01 15:21:04
合計ジャッジ時間 2,685 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<random>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int main(){
	string s;
	cin>>s;
	int r=-1;
	for(int i=0;i+4<=s.size();i++){
		if(s.substr(i,4)=="pain"){
			r=i;
			break;
		}
	}
	if(r==-1)
		cout<<-1<<endl,exit(0);
	int ans=0;
	for(int i=0;i+3<=r;i++)
		if(s.substr(i,3)=="pon")
			ans++;
	cout<<(ans<2?-1:ans-1)<<endl;
}
0