結果

問題 No.1534 おなかがいたい
ユーザー IchimiyaIchimiya
提出日時 2021-06-07 00:04:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 536 bytes
コンパイル時間 1,382 ms
コンパイル使用メモリ 166,008 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-15 13:54:36
合計ジャッジ時間 3,075 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 RE -
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 8 ms
4,384 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 6 ms
4,380 KB
testcase_15 AC 6 ms
4,380 KB
testcase_16 AC 9 ms
4,376 KB
testcase_17 AC 9 ms
4,376 KB
testcase_18 AC 9 ms
4,380 KB
testcase_19 RE -
testcase_20 AC 10 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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