結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,008 KB
testcase_01 AC 16 ms
7,916 KB
testcase_02 AC 16 ms
7,776 KB
testcase_03 AC 16 ms
7,880 KB
testcase_04 AC 15 ms
7,972 KB
testcase_05 WA -
testcase_06 AC 15 ms
7,812 KB
testcase_07 AC 16 ms
7,940 KB
testcase_08 WA -
testcase_09 AC 15 ms
7,920 KB
testcase_10 AC 16 ms
7,836 KB
testcase_11 AC 16 ms
8,020 KB
testcase_12 WA -
testcase_13 AC 93 ms
8,248 KB
testcase_14 AC 114 ms
8,240 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 17 ms
8,324 KB
testcase_20 AC 108 ms
8,268 KB
testcase_21 AC 16 ms
8,004 KB
testcase_22 AC 16 ms
7,908 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
    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