結果
問題 | No.996 Phnom Penh |
ユーザー |
![]() |
提出日時 | 2020-04-22 10:45:46 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 295 bytes |
コンパイル時間 | 171 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 15,760 KB |
最終ジャッジ日時 | 2024-10-11 02:17:49 |
合計ジャッジ時間 | 2,543 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
import re s = input() tt = s.maketrans({'h':None, 'e':'h'}) r = 0 i = 2 while i and ('h' in s or 'e' in s): r += s.count('phnom') + 1 s = s.replace('phnom', 'penh').translate(tt) i -= 1 m = [len(f[0])//2 for f in re.findall('(?<=phn)((om)*)', s)] r += sum(m) + max(m) + 1 if m else 0 print(r)