結果

問題 No.1534 おなかがいたい
コンテスト
ユーザー rainy
提出日時 2021-07-21 14:50:36
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 862 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 168 ms
コンパイル使用メモリ 39,776 KB
最終ジャッジ日時 2026-02-22 07:35:34
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 12 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<stdio.h>

int main(void) {
	char str[200000];
	int count = 0, ponnum = 0, painnum = 0;
	int cheak = 0;
	scanf("%s", str);
	for (int i = 0; i < (sizeof str -sizeof str[0]); i++) {
		if (cheak) {
			break;
		}
		switch (str[i]){
		case 'p':
			ponnum++;
			painnum++;
			break;
		case 'o':
			if (ponnum == 1) {
				ponnum++;
			}else {
				ponnum = 0;
			}
			painnum = 0;
			break;
		case 'n':
			if (painnum==3){
				cheak = 1;
			}
			if (ponnum == 2) {
				count++;
			}
			ponnum = painnum = 0;
			break;
		case 'a':
			if (painnum == 1) {
				painnum++;
			}
			else{
				painnum = 0;
			}
			ponnum = 0;
			break;
		case 'i':
			if (painnum == 2) {
				painnum++;
			}
			else {
				painnum = 0;
			}
			ponnum = 0;
			break;
		default:
			ponnum = painnum = 0;
			break;
		}
	}
	count--;
	if (count < 1) {
		count = -1;
	}
	printf("%d", count);
}
0