Problem Link
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
int t, index;
char S[2014];
cin >> t;
while(t--)
{
scanf("%s", S);
int len = strlen(S);
int i;
for(i = len - 4; i >= 0; i--)
{
if(!(S[i]=='C' || S[i]=='?')) continue;
if(!(S[i+1]=='H' || S[i+1]=='?')) continue;
if(!(S[i+2]=='E' || S[i+2]=='?')) continue;
if(!(S[i+3]=='F' || S[i+3]=='?')) continue;
S[i] = 'C';
S[i+1] = 'H';
S[i+2] = 'E';
S[i+3] = 'F';
}
i = 0;
while(i < len)
{
if(S[i] == '?')
S[i] = 'A';
i++;
}
cout << S << endl;
}
return 0;
}
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
int t, index;
char S[2014];
cin >> t;
while(t--)
{
scanf("%s", S);
int len = strlen(S);
int i;
for(i = len - 4; i >= 0; i--)
{
if(!(S[i]=='C' || S[i]=='?')) continue;
if(!(S[i+1]=='H' || S[i+1]=='?')) continue;
if(!(S[i+2]=='E' || S[i+2]=='?')) continue;
if(!(S[i+3]=='F' || S[i+3]=='?')) continue;
S[i] = 'C';
S[i+1] = 'H';
S[i+2] = 'E';
S[i+3] = 'F';
}
i = 0;
while(i < len)
{
if(S[i] == '?')
S[i] = 'A';
i++;
}
cout << S << endl;
}
return 0;
}
Comments
Post a Comment