fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define mp make_pair
  4. typedef long long ll;
  5. map<ll,bool> m;
  6. const ll MOD=1e16+7;
  7. int main()
  8. {
  9. int n; cin>>n;
  10. for(int i=0;i<n;i++)
  11. {
  12. string s; cin>>s;
  13. ll hash=0;
  14. for(int j=0;j<s.size();j++)
  15. {
  16. hash=hash*4+(ll)(s[j]-'a'+1);
  17. hash=hash%MOD;
  18. }
  19. m[hash]=true;
  20. }
  21. int m; cin>>m;
  22. for(int i=0;i<m;i++)
  23. {
  24. bool flag=false;
  25. string s; cin>>s;
  26. ll hash=0;
  27. for(int j=0;j<s.size();j++)
  28. {
  29. hash=hash*4+(ll)(s[j]-'a'+1);
  30. hash=hash%MOD;
  31. }
  32. ll z=1;
  33. for(int j=s.size()-1;j>=0;j--)
  34. {
  35. for(char c='a';c<='c';c++)
  36. {
  37. if(c!=s[j])
  38. {
  39. ll hash1=hash;
  40. hash1-=(ll)(((s[j]-'a'+1)*z)%MOD);
  41. hash1+=(ll)(((c-'a'+1)*z)%MOD);
  42. hash1=(hash1+MOD)%MOD;
  43.  
  44. if(m[hash1])
  45. {
  46. flag=true;
  47. break;
  48. }
  49. }
  50. }
  51. if(flag==true)
  52. break;
  53. z=z*4;
  54. z=z%MOD;
  55. }
  56. if(flag==true)
  57. cout<<"YES";
  58. else
  59. cout<<"NO";
  60. cout<<endl;
  61. }
  62. return 0;
  63. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:44:31: error: invalid types 'int[ll {aka long long int}]' for array subscript
                     if(m[hash1])
                               ^
stdout
Standard output is empty