Professional Documents
Culture Documents
Robo Prog
Robo Prog
h>
memset(defeated, 0, sizeof(defeated));
// memset(hasR, 0, sizeof(hasR));
// memset(hasP, 0, sizeof(hasP));
// memset(hasS, 0, sizeof(hasS));
cin>>a;
for(i = 0; i < a; i++)
{
string base;
cin>>base;
c[i] = base;
while(c[i].length() < L)
c[i] += base;
string sol;
for(i = 0; i < L; i++)
{
bool hasR, hasP, hasS;
hasR = hasP = hasS = false;
for(j = 0; j < a; j++)
{
if(defeated[j])
continue;
if(c[j][i] == 'R')
hasR = true;
else if(c[j][i] == 'P')
hasP = true;
else if(c[j][i] == 'S')
hasS = true;
}
int cnt = hasR + hasP + hasS;
if(cnt == 1)
{
if(hasR)
sol += "P";
else if(hasP)
sol += "S";
else if(hasS)
sol += "R";
printSolution(number, sol);
return;
}
if(cnt == 2)
{
if(hasR && hasP)
sol += "P";
else if(hasR && hasS)
sol += "R";
else if(hasP && hasS)
sol += "S";
}
else
{
printSolution(number, "IMPOSSIBLE");
return;
}
char x;
if(sol[i] == 'R')
x = 'S';
else if(sol[i] == 'P')
x = 'R';
else if(sol[i] == 'S')
x = 'P';
printSolution(number, sol);
}
int main()
{
int t;
cin>>t;
for(int x = 1; x <= t; x++)
solveTestCase(x);
return 0;;
}