結果

問題 No.996 Phnom Penh
ユーザー titiatitia
提出日時 2020-04-08 05:29:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,930 ms / 2,000 ms
コード長 848 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 10,760 KB
実行使用メモリ 8,784 KB
最終ジャッジ日時 2023-09-23 04:06:28
合計ジャッジ時間 16,553 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,684 KB
testcase_01 AC 16 ms
7,776 KB
testcase_02 AC 16 ms
7,696 KB
testcase_03 AC 17 ms
7,684 KB
testcase_04 AC 16 ms
7,708 KB
testcase_05 AC 18 ms
7,820 KB
testcase_06 AC 16 ms
7,660 KB
testcase_07 AC 16 ms
7,688 KB
testcase_08 AC 18 ms
7,724 KB
testcase_09 AC 22 ms
7,688 KB
testcase_10 AC 16 ms
7,740 KB
testcase_11 AC 17 ms
7,728 KB
testcase_12 AC 17 ms
7,760 KB
testcase_13 AC 1,689 ms
8,604 KB
testcase_14 AC 1,516 ms
8,588 KB
testcase_15 AC 1,545 ms
8,632 KB
testcase_16 AC 1,654 ms
8,784 KB
testcase_17 AC 1,549 ms
8,704 KB
testcase_18 AC 16 ms
7,704 KB
testcase_19 AC 16 ms
7,848 KB
testcase_20 AC 15 ms
8,064 KB
testcase_21 AC 16 ms
7,884 KB
testcase_22 AC 15 ms
8,036 KB
testcase_23 AC 16 ms
7,680 KB
testcase_24 AC 1,930 ms
8,760 KB
testcase_25 AC 1,402 ms
8,724 KB
testcase_26 AC 631 ms
8,536 KB
testcase_27 AC 1,260 ms
8,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S=input()
S+="z"*100

def ope1(SCORE,S):
    T=""
    i=0
    while i<len(S):
        if S[i:i+5]=="phnom":
            T+="pehn"
            i+=5
            SCORE+=1
        else:
            T+=S[i]
            i+=1
    return SCORE,T

def ope2(SCORE,S):
    T=""
    for s in S:
        if s=="h":
            continue
        if s=="e":
            T+="h"
        else:
            T+=s
    if S==T:
        return SCORE,S
    else:
        return SCORE+1,T
    
SCORE=0
SCORE,S=ope1(SCORE,S)
SCORE,S=ope2(SCORE,S)
SCORE,S=ope1(SCORE,S)
SCORE,S=ope2(SCORE,S)
SCORE,S=ope1(SCORE,S)
SCORE,S=ope2(SCORE,S)

LEN=len(S)

L=[]
for i in range(LEN):
    if S[i:i+3]=="phn":
        s=0
        j=i+3
        while S[j:j+2]=="om":
            s+=1
            j+=2
        L.append(s)

if L==[]:
    print(SCORE)
else:
    print(SCORE+max(L)+sum(L)+1)
0