結果

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

テストケース

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

ソースコード

diff #

S = input()

ans = 0
if "phnom" in S:
    ans += 1
    newS = []
    S = list(S)
    S += ["#"]*4
    i = 0
    while i < len(S)-4:
        if S[i] == "p" and S[i+1] == "h" and S[i+2] == "n" and S[i+3] == "o" and S[i+4] == "m":
            newS += ["p", "e", "n", "h"]
            i += 5
        else:
            newS.append(S[i])
            i += 1
    S = "".join(newS)
S = list(S)
newS = []
for i in range(len(S)):
    if S[i] == "e":
        newS.append("h")
    elif S[i] == "h":
        continue
    else:
        newS.append(S[i])

if newS:
    ans += 1
    i = 0
    num = 0
    while i < len(newS)-2:
        if newS[i] == "p" and newS[i+1] == "h" and newS[i+2] == "n":
            j = i+3
            cnt = 0
            while j < len(newS)-1 and newS[j] == "o" and newS[j+1] == "m":
                j += 2
                cnt += 1
            num = max(num, cnt)
            i = j-2
        else:
            i += 1
    if num > 0:
        ans += num*2+1
    elif "h" in newS or "e" in newS:
        ans += 1
print(ans)
0