結果

問題 No.1534 おなかがいたい
ユーザー lloyzlloyz
提出日時 2021-12-21 22:41:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 489 bytes
コンパイル時間 672 ms
コンパイル使用メモリ 10,592 KB
実行使用メモリ 8,428 KB
最終ジャッジ日時 2023-10-13 19:55:13
合計ジャッジ時間 4,117 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,080 KB
testcase_01 AC 16 ms
7,880 KB
testcase_02 AC 15 ms
7,872 KB
testcase_03 AC 16 ms
8,028 KB
testcase_04 AC 16 ms
8,080 KB
testcase_05 WA -
testcase_06 AC 16 ms
7,788 KB
testcase_07 AC 15 ms
7,872 KB
testcase_08 WA -
testcase_09 AC 16 ms
7,944 KB
testcase_10 AC 15 ms
7,936 KB
testcase_11 AC 15 ms
8,040 KB
testcase_12 WA -
testcase_13 AC 88 ms
8,308 KB
testcase_14 AC 99 ms
8,316 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 16 ms
8,424 KB
testcase_20 AC 107 ms
8,416 KB
testcase_21 AC 16 ms
8,088 KB
testcase_22 AC 16 ms
7,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
n = len(S)

pon = "pon"
pon_ind = 0
pain = "pain"
pain_ind = 0
cnt = 0
for i in range(n):
    if S[i] == pon[pon_ind]:
        pon_ind += 1
        if pon_ind == 3:
            cnt += 1
            pon_ind = 0
            continue
    elif pon_ind > 0:
        pon_ind = 0
    if S[i] == pain[pain_ind]:
        pain_ind += 1
        if pain_ind == 4:
            print(cnt - 1)
            exit()
    elif pain_ind > 0:
        pain_ind = 0
print(-1)
0