結果
問題 | No.996 Phnom Penh |
ユーザー | neterukun |
提出日時 | 2020-02-21 22:57:35 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,036 bytes |
コンパイル時間 | 274 ms |
コンパイル使用メモリ | 81,772 KB |
実行使用メモリ | 74,356 KB |
最終ジャッジ日時 | 2024-10-08 22:35:23 |
合計ジャッジ時間 | 2,578 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
52,280 KB |
testcase_01 | AC | 41 ms
52,096 KB |
testcase_02 | AC | 40 ms
52,608 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 37 ms
52,368 KB |
testcase_19 | WA | - |
testcase_20 | AC | 41 ms
52,224 KB |
testcase_21 | AC | 40 ms
51,968 KB |
testcase_22 | AC | 40 ms
51,712 KB |
testcase_23 | AC | 40 ms
51,968 KB |
testcase_24 | AC | 61 ms
66,432 KB |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
ソースコード
s = input() n = len(s) ans = 0 for i in range(n - 4): if s[i:i+4] == "penh": tmp = 0 flag_o = False for j in range(i + 4, n): if s[j] == "h": continue if s[j] == "e": if tmp >= 1: continue else: ans = max(ans, tmp * 2 + 2) break if s[j] == "o" and not flag_o: flag_o = True continue if s[j] == "m" and flag_o: flag_o = False tmp += 1 continue else: ans = max(ans, tmp * 2 + 2) break else: ans = max(ans, tmp * 2 + 2) for i in range(n - 5): if s[i:i+5] == "phnom": tmp = 0 flag_o = False for j in range(i + 5, n): if s[j] == "h": continue if s[j] == "e": if tmp >= 1: continue else: ans = max(ans, tmp * 2 + 3) break if s[j] == "o" and not flag_o: flag_o = True continue if s[j] == "m" and flag_o: flag_o = False tmp += 1 continue else: ans = max(ans, tmp * 2 + 3) break else: ans = max(ans, tmp * 2 + 3) if "h" in s: ans = max(ans, 1) if "e" in s: ans = max(ans, 2) s = s.replace("h", "") s = s.replace("e", "h") n = len(s) for i in range(n - 4): if s[i:i+4] == "penh": tmp = 0 flag_o = False for j in range(i + 4, n): if s[j] == "h": continue if s[j] == "e": if tmp >= 1: continue else: ans = max(ans, tmp * 2 + 3) break if s[j] == "o" and not flag_o: flag_o = True continue if s[j] == "m" and flag_o: flag_o = False tmp += 1 continue else: ans = max(ans, tmp * 2 + 3) break else: ans = max(ans, tmp * 2 + 3) for i in range(n - 5): if s[i:i+5] == "phnom": tmp = 0 flag_o = False for j in range(i + 5, n): if s[j] == "h": continue if s[j] == "e": if tmp >= 1: continue else: ans = max(ans, tmp * 2 + 4) break if s[j] == "o" and not flag_o: flag_o = True continue if s[j] == "m" and flag_o: flag_o = False tmp += 1 continue else: ans = max(ans, tmp * 2 + 4) break else: ans = max(ans, tmp * 2 + 4) print(ans)