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

游游的字母翻倍

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;
}

全部评论

相关推荐

牛客44664404...:把个人技能删了搞这么长干什么!还有你面试要先针对那个公司的技术栈专门去准备,别一问三不知,他需要你会他们公司对口的技术,写这么多不对口没有用
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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