fork(1) download
  1. #include<iostream>
  2. #include<string>
  3. using namespace std;
  4. int main()
  5. {
  6. std::string x;
  7. cin>>x;
  8. int mark[26]={0},ans=1;
  9. for(int i=0;i<x.length();i++)
  10. {
  11. mark[x[i]-97]++;
  12. }
  13. std::string in;
  14. cin>>in;
  15. int n;
  16. cin>>n;
  17. std::string q[n];
  18. for(int i=0;i<n;i++)
  19. {
  20. cin>>q[i];
  21. std::string cpy=in;
  22. int len=q[i].length();
  23. for(int j=0;j<cpy.length();j++)
  24. {if(cpy==q[i]){ans=1;break;}
  25. if(cpy[j]=='?')
  26. {
  27. if(mark[q[i][j]]!=1){ans=0;break;}
  28. else{
  29. std::string p=q[i][j];
  30. cpy.replace(j,1,p);}
  31. }
  32. if(cpy[j]=='*')
  33. {
  34. if(mark[q[i][j]]==1)
  35. {
  36. cpy.erase(j,1);
  37. }
  38. else
  39. {std::string temp;
  40. int m=j;
  41. while(mark[q[i][m]]==0)
  42. {
  43. m++;
  44. std::string p=q[i][m-1];
  45. temp.append(p);
  46. }
  47. cpy.replace(j,m-j,temp);
  48. }
  49. }
  50. else
  51. {
  52. if(cpy[j]!=q[i][j]){ans=0;break;}
  53. }
  54.  
  55. if(ans==0){cout<<"NO"<<endl;}
  56. else{cout<<"YES"<<endl;}
  57. }
  58. }
  59. return 0;
  60. }
  61.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
abc
a?a?a*
4
abacaba
abaca
apapa
aaaaax
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:29:41: error: conversion from ‘__gnu_cxx::__alloc_traits<std::allocator<char> >::value_type {aka char}’ to non-scalar type ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ requested
                     std::string p=q[i][j];
                                         ^
prog.cpp:44:47: error: conversion from ‘__gnu_cxx::__alloc_traits<std::allocator<char> >::value_type {aka char}’ to non-scalar type ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ requested
                         std::string p=q[i][m-1];
                                               ^
stdout
Standard output is empty