結果

問題 No.996 Phnom Penh
ユーザー titiatitia
提出日時 2020-02-21 23:11:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,086 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-04-17 09:14:20
合計ジャッジ時間 3,145 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 28 ms
10,880 KB
testcase_02 AC 30 ms
10,624 KB
testcase_03 AC 28 ms
10,752 KB
testcase_04 AC 29 ms
10,752 KB
testcase_05 WA -
testcase_06 AC 28 ms
10,624 KB
testcase_07 AC 28 ms
10,752 KB
testcase_08 AC 29 ms
10,880 KB
testcase_09 AC 29 ms
10,752 KB
testcase_10 AC 29 ms
10,752 KB
testcase_11 AC 29 ms
10,752 KB
testcase_12 AC 29 ms
10,752 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 29 ms
10,752 KB
testcase_19 WA -
testcase_20 AC 28 ms
10,752 KB
testcase_21 AC 28 ms
10,752 KB
testcase_22 AC 29 ms
10,624 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 201 ms
11,136 KB
testcase_26 AC 207 ms
11,392 KB
testcase_27 AC 194 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

D1=[]
D2=[]

for i in range(LEN):
    if S[i:i+3]=="phn":
        ind=i+3
        while S[ind:ind+2]=="om":
            ind+=2
            while S[ind]=="e" or S[ind]=="h":
                ind+=1

        #print(i,ind)

        D1.append((ind-(i+3))//2)

for i in range(LEN):
    if S[i:i+2]=="om":
        ind=i-1
        while ind>=0 and S[ind]=="h":
            ind-=1

        #print(i,ind)

        if S[ind-2:ind+1]=="pen":

            ind2=i

            while S[ind2:ind2+2]=="om":
                ind2+=2
                while S[ind2]=="e" or S[ind2]=="h":
                    ind2+=1

            if (ind2-i)//2>0:
                D2.append((ind2-i)//2)

if D1==[] and D2==[]:
    if "e" in S:
        print(2)
    elif "h" in S:
        print(1)
    else:
        print(0)
else:
    if D2==[]:
        print(sum(D1)+max(D1)+1)
    elif D1==[]:
        print(sum(D2)+max(D2)+2)
    else:
        if max(D1)>max(D2):
            print(sum(D1)+sum(D2)+max(D1)+1)
        else:
            print(sum(D1)+sum(D2)+max(D2)+2)
            
        
0