結果
問題 |
No.996 Phnom Penh
|
ユーザー |
|
提出日時 | 2020-02-22 03:18:30 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 38 ms / 2,000 ms |
コード長 | 756 bytes |
コンパイル時間 | 114 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 15,660 KB |
最終ジャッジ日時 | 2024-10-09 13:49:09 |
合計ジャッジ時間 | 2,082 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
import re import sys # sys.stdin = open('c.txt') s = input() ans = 0 tr = str.maketrans('e', 'h', 'h') c_op12 = 0 while True: n = s.count('phnom') if n > 0: s = s.replace('phnom', 'penh').translate(tr) ans += n + 1 c_op12 += 1 if c_op12 == 2: match = re.findall('(phn(om)+)', s) if match: max_c = 0 for m in match: c = (len(m[0])-3)//2 ans += c max_c = max(max_c, c) ans += max_c ans += 1 # 最後の操作2の分 break else: if 'h' in s or 'e' in s: s = s.translate(tr) ans += 1 else: break print(ans)