[NOIP2007]字符串的展开 牛子过90% 洛谷AC

https://ac.nowcoder.com/acm/contest/20960/1001

走过路过的大佬来看看秋梨膏QAQ

python写的,不是,哥们,为什么在洛谷能ac,真晕了

a, b, c = map(int, input().split())
S = input()
p = S.find('-')
while p != -1:
    if p == len(S) - 1 or 0:
        p = S.find('-', p + 1)
        continue
    l, r = S[p - 1], S[p + 1]
    ole, ori = ord(l), ord(r)
    tmp = ''
    if (l.isdigit() and r.isdigit()) or (l.isalpha() and r.isalpha()):
        if ori > ole:
            if a != 3:
                for i in range(ole + 1, ori):
                    if chr(i).isalpha() and a == 2:
                        nc = chr(i).upper()
                    else:
                        nc = chr(i)
                    tmp += nc * b
            else:
                nc = '*'
                tmp += nc * b * (ori - ole - 1)
            if c == 2:
                tmp = tmp[::-1]
            S = S[:p] + tmp + S[p + 1:]
    p = S.find('-', p + 1)
print(S)

全部评论
哎呀,第五行写错了,0.0,强烈谴责洛谷
点赞 回复
分享
发布于 04-15 21:25 山东

相关推荐

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