fork download
  1. class BracketSequenceDiv1 {
  2. public:
  3. map<pair<int, string>, int> mapka;
  4. int dp(string& s, int to_cons, string acc) {
  5. if (mapka.count({to_cons, acc})) {
  6. return mapka[{to_cons, acc}];
  7. }
  8. if (to_cons == SZ(s)) {
  9. return (acc == "");
  10. }
  11. if (SZ(s) - to_cons < SZ(acc)) {
  12. return 0;
  13. }
  14. int here = dp(s, to_cons + 1, acc);
  15. string orig = acc;
  16. if (s[to_cons] == '(' || s[to_cons] == '[') {
  17. here += dp(s, to_cons + 1, acc + s[to_cons]);
  18. } else {
  19. if (!acc.empty() && ((s[to_cons] == ']' && acc.back() == '[') || (s[to_cons] == ')' && acc.back() == '('))) {
  20. acc.pop_back();
  21. here += dp(s, to_cons + 1, acc);
  22. }
  23. }
  24. mapka[{to_cons, orig}] = here;
  25. return here;
  26. }
  27. #undef int
  28. long long count(string s) {
  29. #define int long long
  30. return dp(s, 0, "") - 1;
  31. }
  32.  
  33. };
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:3:3: error: 'map' does not name a type
   map<pair<int, string>, int> mapka;
   ^
prog.cpp:4:10: error: 'string' has not been declared
   int dp(string& s, int to_cons, string acc) {
          ^
prog.cpp:4:34: error: 'string' has not been declared
   int dp(string& s, int to_cons, string acc) {
                                  ^
prog.cpp:28:19: error: 'string' has not been declared
   long long count(string s) {
                   ^
prog.cpp: In member function 'int BracketSequenceDiv1::dp(int&, int, int)':
prog.cpp:5:9: error: 'mapka' was not declared in this scope
     if (mapka.count({to_cons, acc})) {
         ^
prog.cpp:8:24: error: 'SZ' was not declared in this scope
     if (to_cons == SZ(s)) {
                        ^
prog.cpp:9:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
       return (acc == "");
                      ^
prog.cpp:11:13: error: 'SZ' was not declared in this scope
     if (SZ(s) - to_cons < SZ(acc)) {
             ^
prog.cpp:15:5: error: 'string' was not declared in this scope
     string orig = acc;
     ^
prog.cpp:16:18: error: invalid types 'int[int]' for array subscript
     if (s[to_cons] == '(' || s[to_cons] == '[') {
                  ^
prog.cpp:16:39: error: invalid types 'int[int]' for array subscript
     if (s[to_cons] == '(' || s[to_cons] == '[') {
                                       ^
prog.cpp:17:49: error: invalid types 'int[int]' for array subscript
       here += dp(s, to_cons + 1, acc + s[to_cons]);
                                                 ^
prog.cpp:19:16: error: request for member 'empty' in 'acc', which is of non-class type 'int'
       if (!acc.empty() && ((s[to_cons] == ']' && acc.back() == '[') || (s[to_cons] == ')' && acc.back() == '('))) {
                ^
prog.cpp:19:38: error: invalid types 'int[int]' for array subscript
       if (!acc.empty() && ((s[to_cons] == ']' && acc.back() == '[') || (s[to_cons] == ')' && acc.back() == '('))) {
                                      ^
prog.cpp:19:54: error: request for member 'back' in 'acc', which is of non-class type 'int'
       if (!acc.empty() && ((s[to_cons] == ']' && acc.back() == '[') || (s[to_cons] == ')' && acc.back() == '('))) {
                                                      ^
prog.cpp:19:82: error: invalid types 'int[int]' for array subscript
       if (!acc.empty() && ((s[to_cons] == ']' && acc.back() == '[') || (s[to_cons] == ')' && acc.back() == '('))) {
                                                                                  ^
prog.cpp:19:98: error: request for member 'back' in 'acc', which is of non-class type 'int'
       if (!acc.empty() && ((s[to_cons] == ']' && acc.back() == '[') || (s[to_cons] == ')' && acc.back() == '('))) {
                                                                                                  ^
prog.cpp:20:13: error: request for member 'pop_back' in 'acc', which is of non-class type 'int'
         acc.pop_back();
             ^
prog.cpp:24:5: error: 'mapka' was not declared in this scope
     mapka[{to_cons, orig}] = here;
     ^
prog.cpp:24:21: error: 'orig' was not declared in this scope
     mapka[{to_cons, orig}] = here;
                     ^
prog.cpp: In member function 'long long int BracketSequenceDiv1::count(int)':
prog.cpp:30:23: error: invalid conversion from 'const char*' to 'int' [-fpermissive]
     return dp(s, 0, "") - 1;
                       ^
prog.cpp:4:7: note:   initializing argument 3 of 'int BracketSequenceDiv1::dp(int&, int, int)'
   int dp(string& s, int to_cons, string acc) {
       ^
stdout
Standard output is empty