結果
問題 |
No.996 Phnom Penh
|
ユーザー |
![]() |
提出日時 | 2025-06-12 20:29:44 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 879 bytes |
コンパイル時間 | 161 ms |
コンパイル使用メモリ | 82,904 KB |
実行使用メモリ | 249,972 KB |
最終ジャッジ日時 | 2025-06-12 20:30:04 |
合計ジャッジ時間 | 15,122 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 TLE * 6 -- * 3 |
ソースコード
def max_operations(S): current = S count = 0 while True: # Apply all possible operation 1 new_str = current while True: index = new_str.find('phnom') if index == -1: break new_str = new_str[:index] + 'penh' + new_str[index+5:] count += 1 if new_str == current: # No change in operation 1, try operation 2 # Apply operation 2 temp = new_str.replace('h', '') temp = temp.replace('e', 'h') if temp != new_str: count += 1 new_str = temp else: # No change in operation 2, break break current = new_str return count # Read input S = input().strip() # Compute result result = max_operations(S) # Output the result print(result)