题解 | #万万没想到之聪明的编辑#

import sys
import re

def correct(s):
    s = re.sub(r'(\w)\1{2,}', r'\1\1', s)  # 2+转2
    s = re.sub(r'(\w)\1(\w)\2', r'\1\1\2', s)  # AABB转AAB
    return s

for line in sys.stdin:
    a = line.split()
    s = a[0]
    if not s.isdigit():
        print(correct(s))
全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务