結果
問題 |
No.996 Phnom Penh
|
ユーザー |
|
提出日時 | 2020-02-21 23:09:48 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 829 bytes |
コンパイル時間 | 378 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 109,056 KB |
最終ジャッジ日時 | 2024-10-09 02:10:10 |
合計ジャッジ時間 | 2,664 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 WA * 18 RE * 1 |
ソースコード
import sys def D(*a, **kwa): print(*a, file=sys.stderr, **kwa) pm = 'phnom' ph = 'penh' can_op1 = lambda s: pm in s can_op2 = lambda s: 'h' in s or 'e' in s tr = str.maketrans('e', 'h', 'h') op1 = lambda s: s.replace(pm, ph) op2 = lambda s: s.translate(tr) def solve(op, s, hist): if op == 1: if can_op1(s): s = op1(s) hist = hist + '1' return solve(2, s, hist) else: return hist else: if can_op2(s): s = op2(s) hist = hist + '2' h1 = solve(1, s, hist) h2 = solve(2, s, hist) return h1 if len(h1) > len(h2) else h2 else: return hist S = input() ans = 0 for i in range(1, 2+1): hist = solve(i, S, '') # D(hist) ans = max(ans, len(hist)) print(ans)