結果
| 問題 |
No.996 Phnom Penh
|
| コンテスト | |
| ユーザー |
ttr
|
| 提出日時 | 2020-02-21 22:16:21 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,031 bytes |
| コンパイル時間 | 302 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 14,104 KB |
| 最終ジャッジ日時 | 2024-10-08 21:52:22 |
| 合計ジャッジ時間 | 3,819 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 3 WA * 22 |
ソースコード
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)
ttr