思路:用贪心去做,直接先遍历一遍找到数量最多的那个就行。
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;cin>>t;
while(t--){
string str; cin>>str;
char ans;
int r=0,s=0,p=0;
for(int i=0;i<str.length();i++){
if(str[i]=='R') r++;
else if(str[i]=='S') s++;
else p++;
}
if(p>=r&&p>=s) ans = 'S';
else if(r>=p&&r>=s) ans = 'P';
else ans = 'R';
for(int i=0;i<str.length();i++) cout<<ans;
cout<<endl;
}
return 0;
}