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