fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.  
  7. string m,n;
  8. cin>>m>>n;
  9. int i;bool fd=0;
  10. for(i=0;i<=(int)(m.size()-n.size());i++)
  11. { int ans=0;
  12. for(int j=0;j<(int)n.size();j++)
  13. {
  14. if(m[j+i]==n[j] || m[j+i]=='?')
  15. {
  16. ans++;
  17. }
  18.  
  19. }
  20. if(ans==(int)n.size()){
  21. fd=1;
  22. break;
  23. }
  24.  
  25. }
  26. if(fd){
  27. string ap="";
  28.  
  29. for(int j=0;j<m.size();j++) {
  30. if (m[j] == '?')
  31. m[j] = 'a';
  32.  
  33. }
  34.  
  35. for(int j=0;j<i;j++)
  36. cout<<m[j];
  37. for(int j=0;j<n.size();j++)
  38. cout<<n[j];
  39.  
  40.  
  41. for(int e=i+n.size();e<m.size();e++)
  42. cout<<m[e];
  43. cout<<endl;
  44.  
  45. }else{
  46. cout<<"UNRESTORABLE\n";
  47. }
  48.  
  49. return 0;
  50. }
  51.  
Success #stdin #stdout 0s 4476KB
stdin
?tc????
coder
stdout
atcoder