結果

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

ソースコード

diff #

// yukicoder: 1534 おなかがいたい
// 2021.8.14

#include <stdio.h>
#include <string.h>

char S[200005];

int main() {
	char *s;
	int c = 0;
	scanf("%s", s = S);
	while (*s) {
		if (!memcmp(s, "pon", 3)) s += 2, c++;
		else if (!memcmp(s, "pain", 4)) {
			printf("%d\n", c >= 2? c-1: -1);
			return 0; 
		}
		++s;
	}
	puts("-1");
	return 0;
}
0