王99998 @ 2022-01-23 12:30:08
#include <bits/stdc++.h>
using namespace std;
string ch;
int b[1000001],ans;
int main() {
cin>>ch;
int n=ch.size();
for(int i=0;i<n;i++){
if(ch[i]=='R'){
b[i+1]=b[i]+1;
}
else{
b[i+1]=b[i]-1;
}
}
for(int j=n;j>1;j--){
for(int i=0;i<j;i++){
if(b[i]==b[j]){
ans=max(ans,j-i);
}
}
}
cout<<ans;
return 0;
}
by 王99998 @ 2022-01-23 12:32:21
这里是AC记录
by OldVagrant @ 2022-01-23 12:34:49
数据的确水了
by like_rain @ 2023-02-01 20:53:40
我
by Sesen @ 2023-03-08 09:06:31