結果

問題 No.996 Phnom Penh
ユーザー convexineqconvexineq
提出日時 2020-02-21 23:30:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,571 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 12,840 KB
最終ジャッジ日時 2024-04-17 09:28:21
合計ジャッジ時間 1,837 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

# coding: utf-8
# Your code here!

import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,*a = [int(i) for i in read().split()]
#a = [int(i) for i in readline().split()]
#n = int(input())

s = input()

ans = 0
c = s.count("phnom")
if c==0: 
    if "h" in s or "e" in s:
        ans = 1
        s = s.replace("h","").replace("e","h")
        c = s.count("phnom")
        if c==0:
            if "h" in s or "e" in s:
                print(ans+1)
                exit()
            else:
                print(ans)
                exit()
    else:
        print(0)
        exit()

s = s.replace("phnom","penh").replace("h","").replace("e","h")
ans += c+1

c = s.count("phnom")
if c==0: 
    if "h" in s or "e" in s:
        ans += 1
        s = s.replace("h","").replace("e","h")
        c = s.count("phnom")
        if c==0:
            if "h" in s or "e" in s:
                print(ans+1)
                exit()
            else:
                print(ans)
                exit()
    else:
        print(0)
        exit()



s = s.replace("phn","X").replace("om","Y")


def getans(s,ans):
    q = []
    res = 0
    depth = 0
    for i in s[::-1]:
        if not q: q.append(i)
        else:
            if i=="X":
                r = 0
                while q and q[-1]=="Y":
                    q.pop()
                    r += 1
                res += r
                depth = max(depth,r)
            q.append(i)
    
    
    if res==0:
        print(ans+1)
        exit()
    else:
        print(ans+res+depth+1)

getans(s,ans)







    











0