文章

83

粉丝

2

获赞

546

访问

24.9k

头像
查找 - 北邮 题解:
P1387 北京邮电大学
发布于2026年3月17日 21:54
阅读数 384

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    string s;
    
    while(cin >> s){
        int n;
        cin >> n;

        while(n--){
            string op;
            cin >> op;

            int type = op[0] - '0';   
            int i = op[1] - '0';     
            int len = op[2] - '0';    

            if(type == 0){
                reverse(s.begin() + i, s.begin() + i + len);
            }
            else{
                string t = op.substr(3); 
                s.replace(i, len, t);
            }

            cout << s << endl;
        }
    }

    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发