-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy patharray.cpp
80 lines (77 loc) · 897 Bytes
/
array.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <iostream>
#include <cstring>
using namespace std;
char s2[1010];
int main()
{
int t;
cin>>t;
while(t--)
{
memset(s2,0,sizeof s2);
int n;
cin>>n;
int r1,p1,s1;
cin>>r1>>p1>>s1;
string st;
cin>>st;
int win=0;
for(int i=0;i<st.size();i++)
{
if(st[i]=='R')
{
if(p1>0)
{
p1--;
s2[i]='P';
win++;
}
}
else if(st[i]=='S')
{
if(r1>0)
{
r1--;
s2[i]='R';
win++;
}
}
else if(st[i]=='P')
{
if(s1>0)
{
s1--;
s2[i]='S';
win++;
}
}
}
if(win>=(n+1)/2)
{
cout<<"YES"<<endl;
for(int i=0;i<n;i++)
{
if(!s2[i])
{
if(r1>0)
{
s2[i]='R';
r1--;
}
else if(p1>0)
{
s2[i]='P';
p1--;
}
else if(s1>0)
{
s2[i]='S';
s1--;
}
}
}
cout<<s2<<endl;
}
else cout<<"NO"<<endl;
}
}