結果
| 問題 | 
                            No.1534 おなかがいたい
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Ichimiya
                         | 
                    
| 提出日時 | 2021-06-07 00:08:35 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 11 ms / 2,000 ms | 
| コード長 | 580 bytes | 
| コンパイル時間 | 1,470 ms | 
| コンパイル使用メモリ | 167,052 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-23 21:26:58 | 
| 合計ジャッジ時間 | 2,318 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 19 | 
ソースコード
#include <bits/stdc++.h>
#define NIL (-1)
#define ll long long
using namespace std;
const double PI = acos(-1.0);
int main() {
	string S;
	cin >> S;
	int s = S.find("pain");
	if (s == string::npos) {
		cout << -1 << endl;
		return 0;
	}
	//cout << s << endl;
	string T = S.substr(0, s);
	//cout << T.size() - 2 << endl;
	if (T.size() < 3) {
		cout << -1 << endl;
		return 0;
	}
	int co = 0;
	for (int i = 0; i < T.size()-2; i++) {
		string t = T.substr(i, 3);
		if (t == "pon") co++;
	}
	if (co < 2) {
		cout << -1 << endl;
		return 0;
	}
	cout << co - 1 << endl;
	return 0;
}
            
            
            
        
            
Ichimiya