結果

問題 No.1534 おなかがいたい
ユーザー Ichimiya
提出日時 2021-06-07 00:04:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 536 bytes
コンパイル時間 1,526 ms
コンパイル使用メモリ 166,800 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-23 21:21:16
合計ジャッジ時間 3,213 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 << S+T << endl;
	int co = 0;
	for (int i = 0; i < T.size()-2; i++) {
		string t = T.substr(i, 3);
		//cout << t << endl;
		if (t == "pon") co++;
	}
	if (co < 2) {
		cout << -1 << endl;
		return 0;
	}
	cout << co - 1 << endl;

	return 0;
}
0