1 条题解

  • 0
    @ 2026-1-11 10:47:33

    STL大法好!!!能用STL就用STL,随机数据太玄学了,跑的飞快!!! code:

    #include<bits/stdc++.h>
    using namespace std;
    int n,m;
    string s;
    int main(){
        ios::sync_with_stdio(0);cin.tie(0);
        cin>>s>>m;n=s.size();
        for(int i=0;i<m;i++){
            string op;cin>>op;
            if(op=="Q"){
                int x,d;cin>>x>>d;x--,d--;
                int l=0;
                for(int i=x,j=d;i<n&&j<n;i++,j++){
                    if(s[i]==s[j])l++;
                    else break;
                }
                cout<<l<<"\n";
            }else if(op=="R"){
                int x;string c;cin>>x>>c;
                s[x-1]=c[0];
            }else{
                int x;string c;cin>>x>>c;
                s.insert(x,c);n=s.size();
            }
        }
        return 0;
    }
    

    信息

    ID
    2986
    时间
    1000ms
    内存
    512MiB
    难度
    8
    标签
    递交数
    1
    已通过
    1
    上传者