結果
| 問題 | No.1534 おなかがいたい |
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 18:53:01 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 45 ms / 2,000 ms |
| コード長 | 495 bytes |
| コンパイル時間 | 157 ms |
| コンパイル使用メモリ | 82,372 KB |
| 実行使用メモリ | 63,020 KB |
| 最終ジャッジ日時 | 2025-03-20 18:54:03 |
| 合計ジャッジ時間 | 2,094 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
s = input().strip()
# Find the first occurrence of 'pain'
pain_start = s.find('pain')
if pain_start == -1:
print(-1)
else:
# Extract the substring before the first 'pain'
substring = s[:pain_start]
count = 0
# Iterate through the substring to count 'pon's
for i in range(len(substring) - 2):
if substring[i] == 'p' and substring[i+1] == 'o' and substring[i+2] == 'n':
count += 1
if count < 2:
print(-1)
else:
print(count - 1)
lam6er