Practice
Contest Link
Problem Link
Author: Srinjoy Pal
Tester: Akash Kumar Bhagat
Editorialist: Srinjoy Pal
DIFFICULTY:
CAKEWALK
PREREQUISITES:
Basic understanding , https://en.wikipedia.org/wiki/Rock_paper_scissors\
PROBLEM:
Traverse through the array for first W+L moves and make the required changes.
EXPLANATION:
For first W moves change the P to S , R to P and S to R so that Coco wins exactly W times .
For the next L moves change the P to R , R to S and S to P so that Coco loses exactly L times .
And keeps the rest of the moves same as that of the string so that Coco draws the rest of the games.
SOLUTION:
int main() {
int t;
cin>>t;
while(t--)
{
int w,l,i=0;
cin>>w>>l;
string s;
cin>>s;
char arr[26];
arr['R'-'A']='P';
arr['P'-'A']='S';
arr['S'-'A']='R';
while(i<w)
{
s[i]=arr[s[i]-'A'];
i++;
}
while(i<(w+l))
{
s[i]=arr[arr[s[i]-'A']-'A'];
i++;
}
for(i=0;i<s.size();i++)
cout<<s[i];
cout<<"\n";
}
return 0;
}