Solution in c++
#include <iostream>
#include <map>
using namespace std;
map<char,int> alpha;
int acc,sz,mx=25;
int main()
{
if(1==2)
{
en:
cout<<-1;
return 0;
}
string inp;cin>>inp;
sz=inp.size();
mx=sz-1;
again:
while(mx>=25)
{
acc=0;
alpha.clear();
for(int i=mx-25;i<=mx;i++)
{
if(++alpha[inp[i]]==1)acc++;
else if(inp[i]=='?')
{
acc++;
alpha['?']++;
}
else
{
mx--;
goto again;
}
}
if(acc==26)
{
for(int k=0;k<sz;k++)
{
if(k<mx-25 || k>mx)cout<<((inp[k]=='?')?'S':inp[k]);
else {
if(inp[k]!='?'){cout<<inp[k];continue;}
for(int y='A';y<='Z';y++)
{
if(alpha[char(y)]==0)
{
cout<<char(y);
alpha[char(y)]++;
y='Z'+1;
}
}
}
}
return 0;
}
}
goto en;
return 0;
}
Aacicluki Justine Higgins link
ردحذفenintruscal