fork download
  1. typedef long long int lli;
  2. typedef unsigned long long int ulli;
  3. typedef long double ldb;
  4.  
  5. #define pb push_back
  6. #define popb pop_back()
  7. #define pf push_front
  8. #define popf pop_front()
  9.  
  10. #define si size()
  11. #define be begin()
  12. #define en end()
  13. #define all(v) v.be, v.en
  14.  
  15. #define le length()
  16. #define mp make_pair
  17. #define mt make_tuple
  18. #define acc(v) accumulate(all(v), 0)
  19. #define F first
  20. #define S second
  21.  
  22. #define pll pair<lli, lli>
  23. #define pii pair<int, int>
  24. #define pil pair<int, lli>
  25.  
  26. #define forz(i, n) for (int i = 0; i < n; i++)
  27. #define fore(i, m, n) for (int i = m; i <= n; i++)
  28. #define rforz(i, n) for (int i = n - 1; i >= 0; i--)
  29. #define rfore(i, m, n) for (int i = n; i >= m; i--)
  30.  
  31. #define mod 1000000007
  32. #define mod2 998244353
  33. #define gcd __gcd
  34. #define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
  35.  
  36. #define deci(n) fixed << setprecision(n)
  37. #define high(n) __builtin_popcount(n)
  38. #define highll(n) __builtin_popcountll(n)
  39. #define parity(n) __builtin_parity(n)
  40. #define ctz(n) __builtin_ctz(n)
  41.  
  42. #define bset(a, p) ((a) | (1ll << (p)))
  43. #define bchk(a, p) ((a) & (1ll << (p)))
  44. #define bxor(a, p) ((a) ^ (1ll << (p)));
  45. #define brem(a, p) (bchk(a, p) ? (bxor(a, p)) : (a))
  46. int phi[505][26];
  47. int num;
  48. int dp[1005][105][2][2];
  49. int match(string t, string s)
  50. {
  51. int m = int(t.si);
  52. int n = int(s.si);
  53. for (int i = n - m; i < n; i++)
  54. {
  55. if (s[i] != t[i + m - n])
  56. return 0;
  57. }
  58. return 1;
  59. }
  60. int presuf(string t, string s)
  61. {
  62. int m = int(t.si);
  63. for (int i = int(s.si); i >= 1; i--)
  64. {
  65. if (match(t.substr(0, i), s))
  66. return i;
  67. }
  68. return 0;
  69. }
  70. int m;
  71. string a, b;
  72. lli solve(int pos, int st, int t1, int t2)
  73. {
  74. if (pos == num)
  75. return (st != m);
  76.  
  77. if (dp[pos][st][t1][t2] != -1)
  78. return dp[pos][st][t1][t2];
  79.  
  80. lli ans = 0;
  81. int srt = t1 ? a[pos] - 'a' : 0;
  82. int ert = t2 ? b[pos] - 'a' : 25;
  83.  
  84. for (int i = srt; i <= ert; i++)
  85. {
  86. ans = (ans + solve(pos + 1, phi[st][i], t1 && (i == srt), t2 && (i == ert))) % mod;
  87. }
  88. return dp[pos][st][t1][t2] = ans;
  89. }
  90. class Solution
  91. {
  92. public:
  93. int findGoodStrings(int n, string s1, string s2, string evil)
  94. {
  95. a = s1;
  96. b = s2;
  97. num = n;
  98. string s = evil;
  99. m = int(s.si);
  100. vector<string> v(m + 1, "");
  101. for (int i = 1; i <= m; i++)
  102. {
  103. v[i] = v[i - 1];
  104. v[i] += s[i - 1];
  105. }
  106. for (int i = 0; i <= m; i++)
  107. {
  108. for (int j = 0; j <= 25; j++)
  109. {
  110. phi[i][j] = presuf(s, v[i] + char('a' + j));
  111. if (i == m)
  112. phi[i][j] = m;
  113. }
  114. }
  115. memset(dp, -1, sizeof(dp));
  116. return solve(0, 0, 1, 1);
  117. }
  118. };
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:49:11: error: ‘string’ was not declared in this scope
 int match(string t, string s)
           ^~~~~~
prog.cpp:49:11: note: suggested alternative: ‘struct’
 int match(string t, string s)
           ^~~~~~
           struct
prog.cpp:49:21: error: ‘string’ was not declared in this scope
 int match(string t, string s)
                     ^~~~~~
prog.cpp:49:21: note: suggested alternative: ‘struct’
 int match(string t, string s)
                     ^~~~~~
                     struct
prog.cpp:49:29: error: expression list treated as compound expression in initializer [-fpermissive]
 int match(string t, string s)
                             ^
prog.cpp:60:12: error: ‘string’ was not declared in this scope
 int presuf(string t, string s)
            ^~~~~~
prog.cpp:60:12: note: suggested alternative: ‘struct’
 int presuf(string t, string s)
            ^~~~~~
            struct
prog.cpp:60:22: error: ‘string’ was not declared in this scope
 int presuf(string t, string s)
                      ^~~~~~
prog.cpp:60:22: note: suggested alternative: ‘struct’
 int presuf(string t, string s)
                      ^~~~~~
                      struct
prog.cpp:60:30: error: expression list treated as compound expression in initializer [-fpermissive]
 int presuf(string t, string s)
                              ^
prog.cpp:71:1: error: ‘string’ does not name a type; did you mean ‘struct’?
 string a, b;
 ^~~~~~
 struct
prog.cpp: In function ‘lli solve(int, int, int, int)’:
prog.cpp:81:20: error: ‘a’ was not declared in this scope
     int srt = t1 ? a[pos] - 'a' : 0;
                    ^
prog.cpp:82:20: error: ‘b’ was not declared in this scope
     int ert = t2 ? b[pos] - 'a' : 25;
                    ^
prog.cpp: At global scope:
prog.cpp:93:32: error: ‘string’ has not been declared
     int findGoodStrings(int n, string s1, string s2, string evil)
                                ^~~~~~
prog.cpp:93:43: error: ‘string’ has not been declared
     int findGoodStrings(int n, string s1, string s2, string evil)
                                           ^~~~~~
prog.cpp:93:54: error: ‘string’ has not been declared
     int findGoodStrings(int n, string s1, string s2, string evil)
                                                      ^~~~~~
prog.cpp: In member function ‘int Solution::findGoodStrings(int, int, int, int)’:
prog.cpp:95:9: error: ‘a’ was not declared in this scope
         a = s1;
         ^
prog.cpp:96:9: error: ‘b’ was not declared in this scope
         b = s2;
         ^
prog.cpp:98:9: error: ‘string’ was not declared in this scope
         string s = evil;
         ^~~~~~
prog.cpp:98:9: note: suggested alternative: ‘struct’
         string s = evil;
         ^~~~~~
         struct
prog.cpp:99:17: error: ‘s’ was not declared in this scope
         m = int(s.si);
                 ^
prog.cpp:100:9: error: ‘vector’ was not declared in this scope
         vector<string> v(m + 1, "");
         ^~~~~~
prog.cpp:100:24: error: ‘v’ was not declared in this scope
         vector<string> v(m + 1, "");
                        ^
prog.cpp:110:59: error: ‘presuf’ cannot be used as a function
                 phi[i][j] = presuf(s, v[i] + char('a' + j));
                                                           ^
prog.cpp:115:9: error: ‘memset’ was not declared in this scope
         memset(dp, -1, sizeof(dp));
         ^~~~~~
prog.cpp:115:9: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
prog.cpp:1:1:
+#include <cstring>
 typedef long long int lli;
prog.cpp:115:9:
         memset(dp, -1, sizeof(dp));
         ^~~~~~
stdout
Standard output is empty