結果
| 問題 |
No.996 Phnom Penh
|
| コンテスト | |
| ユーザー |
vwxyz
|
| 提出日時 | 2024-07-16 23:40:42 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 774 ms / 2,000 ms |
| コード長 | 851 bytes |
| コンパイル時間 | 216 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 14,208 KB |
| 最終ジャッジ日時 | 2024-07-16 23:40:51 |
| 合計ジャッジ時間 | 7,710 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
S=list(input())
def operate(S,T0,T1):
queue=[]
cnt=0
for s in S:
queue.append(s)
while len(queue)>=len(T0) and queue[len(queue)-len(T0):]==T0:
for _ in range(len(T0)):
queue.pop()
for t in T1:
queue.append(t)
cnt+=1
return queue,cnt
ans=0
for _ in range(2):
S,cnt=operate(S,list("phnom"),list("penh"))
ans+=cnt
if "h" in S or "e" in S:
S,_=operate(S,["h"],[])
S,_=operate(S,["e"],["h"])
ans+=1
queue=[]
cnt=[]
for s in S:
queue.append(s)
if len(queue)>=5 and queue[-5:]==list("phnom"):
cnt.append(1)
elif len(queue)>=7 and queue[-7:]==list("phnomom"):
for _ in range(2):
queue.pop()
cnt[-1]+=1
if cnt:
ans+=sum(cnt)+max(cnt)+1
elif "h" in S:
ans+=1
print(ans)
vwxyz