結果

問題 No.1534 おなかがいたい
ユーザー rainyrainy
提出日時 2021-07-21 14:51:37
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 875 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 28,692 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-24 13:08:44
合計ジャッジ時間 1,057 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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 ||cheak == 0) {
		count = -1;
	}
	printf("%d", count);
}
0