Result: Accepted
Time: 1ms
Memory: 1704kB
#include<cstdio>
#include <string>
#include <string.h>
#include <cmath>
#include<stack>
#include <queue>
#include <map>
#include <vector>
#include <cstdlib>
#include <iostream>
#include<algorithm>
#include <cctype>
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y)
{
return y == 0? x:gcd(y, x%y);
}
ll lcm(ll x, ll y)
{
return x/gcd(x,y)*y;
}
ll pow_mod(ll a,ll n, ll mod)
{
ll res=1;
while(n)
{
if(n&1)res= res*a%mod;
a=a*a%mod;
n>>=1;
}
return res;
}
/*
input:1 0.0001
output:0.36788
*/
double fun(double x[10])
{
int i;
long t;
double avg=0,sum=0;
for(int i =0 ;i < 10;i++)
{
sum+=x[i];
}
avg=sum*100;
t=avg;
avg=(double)t/100;
return avg;
}
struct node
{
string name;
int a,b;
};
bool com(const node &x,const node &y)
{
return x.a+x.b>y.a+y.b;
}
typedef unsigned long long ull;
char a[120];
bool c1(char a[])
{
for(int i=0;i<3;i++)a[i]=tolower(a[i]);
if(strcmp(a,"ssr")==0)return true;
else return false;
}
bool c2(char a[])
{
for(int i=0;i<6;i++)a[i]=tolower(a[i]);
if(strcmp(a,"africa")==0)return true;
else return false;
}
int main()
{
int T;
cin>>T;
getchar();
while(T--)
{
gets(a);
for(int i =0;a[i]!=0;)
{
char t[50];
memset(t,0,sizeof t);
for(int j=0;j<3;j++)t[j]=a[i+j];
if(c1(t))
{
printf("***");
i+=3;
continue;
}
for(int j=0;j<6;j++)t[j]=a[i+j];
if(c2(t))
{
printf("AFRICA");
i+=6;
continue;
}
printf("%c",a[i]);
i++;
}
cout<<endl;
}
}