Result: Accepted
Time: 1ms
Memory: 1096kB
#include<stdio.h>
#include<string.h>
int main()
{
int t;
scanf("%d",&t);
getchar();
while(t--)
{
char a[111];
gets(a);
int i;
for(i=2;i<strlen(a);i++)
{
if((a[i-2]=='s'||a[i-2]=='S')&&(a[i-1]=='s'||a[i-1]=='S')&&(a[i]=='R'||a[i]=='r'))
a[i-2]='*',a[i-1]='*',a[i]='*';
if(i>5)
{
if((a[i-5]=='A'||a[i-5]=='a')&&(a[i-4]=='f'||a[i-4]=='F')&&(a[i-3]=='r'||a[i-3]=='R')&&(a[i-2]=='i'||a[i-2]=='I')&&(a[i-1]=='c'||a[i-1]=='C')&&(a[i]=='A'||a[i]=='a'))
a[i-5]='A',a[i-4]='F',a[i-3]='R',a[i-2]='I',a[i-1]='C',a[i]='A';
}
}
puts(a);
}
}