結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

string s;
int n = -1;
bool f;

int main()
{
	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		if (s.substr(i, 3) == "pon") {
			n++;
			i += 2;
		}
		else if (s.substr(i, 4) == "pain") {
			f = 1;
			break;
		}
	}
	
	if (f && n > 0)
		cout << n << endl;
	else
		cout << -1 << endl;
}
0