Skip to content

Commit 36c32c5

Browse files
committed
Finish question D
1 parent cbf0973 commit 36c32c5

File tree

1 file changed

+24
-0
lines changed
  • アルゴリズム実技検定 過去問/第七回 アルゴリズム実技検定 過去問

1 file changed

+24
-0
lines changed

アルゴリズム実技検定 過去問/第七回 アルゴリズム実技検定 過去問/D - 書き換え.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,27 @@
1616
1≤N≤2×10^5
1717
S は 英小文字からなる長さ N の文字列。
1818
"""
19+
20+
21+
class Solution:
22+
@staticmethod
23+
def replace_strings(s: str) -> str:
24+
result = ""
25+
match_sets = {"axa", "ixi", "uxu", "exe", "oxo"}
26+
27+
i = 0
28+
while i < len(s):
29+
if s[i:i + 3] in match_sets:
30+
result += "..."
31+
i += 3
32+
else:
33+
result += s[i]
34+
i += 1
35+
36+
return result
37+
38+
39+
if __name__ == '__main__':
40+
N = int(input())
41+
S = input()
42+
print(Solution.replace_strings(S))

0 commit comments

Comments
 (0)