結果
| 問題 |
No.996 Phnom Penh
|
| コンテスト | |
| ユーザー |
vwxyz
|
| 提出日時 | 2024-07-16 22:51:06 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 684 bytes |
| コンパイル時間 | 299 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 14,188 KB |
| 最終ジャッジ日時 | 2024-07-16 22:51:12 |
| 合計ジャッジ時間 | 5,856 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 WA * 10 |
ソースコード
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
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=[]
for s in S:
queue.append(s)
if len(queue)>=5 and queue[-5:]==list("phnom"):
for _ in range(2):
queue.pop()
ans+=2
if "h" in queue:
ans+=1
print(ans)
vwxyz