模拟(Python)

游游的字母翻倍

https://www.nowcoder.com/practice/cd02bff88b6f4f4fba264dccdb78705d

思路:模拟题,算一下时间复杂度可以得到是。由于q只有10,那么量级就是,为,完全可以通过

tips:Python3处理字符串的效率高于PyPy3,因此这题用Python3跑的速度快于PyPy3

代码:

import sys
input = lambda: sys.stdin.readline().strip()

import math
inf = 10 ** 18

def I():
    return input()

def II():
    return int(input())

def MII():
    return map(int, input().split())

def GMI():
    return map(lambda x: int(x) - 1, input().split())

def LI():
    return input().split()

def LII():
    return list(map(int, input().split()))

def LFI():
    return list(map(float, input().split()))

fmax = lambda x, y: x if x > y else y
fmin = lambda x, y: x if x < y else y
isqrt = lambda x: int(math.sqrt(x))

'''

'''

def solve():
    n, q = MII()
    s = I()
    for _ in range(q):
        res = ''
        l, r = MII()
        l -= 1
        for i in range(l, r):
            c = s[i]
            res += c * 2
        s = s[:l] + res + s[r:]
    print(s)


t = 1
# t = II()
for _ in range(t):
    solve()
#每日一题挑战#
全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务