题解 | #游游的字母翻倍#

游游的字母翻倍

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

// By SnowDream
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10;

string s,tmp;
int n,q,l,r;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> q;
    cin >> s;
    while(q--)
    {
        cin >> l >> r;
        tmp= "";
        for(int i=l-1;i<r;i++)
        {
            string tmp1(2,s[i]);
            tmp+=tmp1;
        }
        s.replace(l-1,r-l+1,tmp);
    }
    cout << s;
    cout <<"\n";
    return 0;
}

全部评论

相关推荐

11-07 16:07
深圳大学 运营
前端飞升:学长,阿里不是卡双非吗,我深也能去吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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