結果

問題 No.996 Phnom Penh
ユーザー maspy
提出日時 2020-04-08 15:28:44
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 795 bytes
コンパイル時間 66 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 12,800 KB
最終ジャッジ日時 2024-07-18 13:15:47
合計ジャッジ時間 2,184 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = read().rstrip().decode()
op1 = S.count('phnom')
S = S.replace('phnom', 'penh')
T = S.replace('h', '').replace('e', 'h')

if S == T:
    print(op1)
    exit()
S = T


def solve(S):
    assert not S.count('e')
    if not S.startswith('phn'):
        if S.count('h'):
            return 0, 1
        else:
            return 0, 0
    # phn + om * k -> phn
    S = S[3:].replace('om', 'X')
    k = 0
    for i, x in enumerate(S):
        if x == 'X':
            k += 1
        else:
            break
    return k, k + 1


op2 = 1
for x, y in map(solve, S.replace('p', ' p').split()):
    op1 += x
    if op2 < 1 + y:
        op2 = 1 + y
print(op1 + op2)
0