1 条题解

  • 0
    @ 2025-1-17 11:34:43
    #include <bits/stdc++.h>
    using namespace std;
    string s;
    int n,l,r;
    int main(){
    cin>>s;
    n=s.length();
    for (int i=0;i<n;i++){
    
    
    if (s[i]=='N'){
    l=i;r=l;
    while (s[r]=='N'){
    r++;
    }
    if (s[l-1]=='R'&&s[r]=='L'){
    for (int l1=l,r1=r-1;l1<r1;l1++,r1--){
    s[l1]='R';s[r1]='L';
    }
    }
    else if (s[l-1]=='R'){
    for (int j=l;j<r;j++){
    s[j]='R';
    }
    }
    else if (s[r]=='L'){
    for (int j=l;j<r;j++){
    s[j]='L';
    }
    }
    i=r-1;
    }
    
    }
    cout<<s;
    return 0;
    
    
    }
    
    

    信息

    ID
    4392
    时间
    1000ms
    内存
    256MiB
    难度
    9
    标签
    (无)
    递交数
    42
    已通过
    4
    上传者