Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int n;
  8. vector<string> sk[15];
  9.  
  10.  
  11. int main(){
  12.     ios_base::sync_with_stdio(0);
  13.     cin.tie(0);
  14.     cin >> n;
  15.     n/=2;
  16.     sk[0].push_back("");
  17.     sk[1].push_back("()");
  18.     sk[1].push_back("[]");
  19.     for(int i = 2; i <= n; ++i){
  20.         for(int j = 0; j < i; ++j){
  21.             for(string& k1: sk[j])
  22.                 for(string& k2: sk[i-1-j])
  23.                     sk[i].push_back("("+k1+")"+k2),
  24.                     sk[i].push_back("["+k1+"]"+k2);
  25.         }
  26.     }
  27.     for(string& a: sk[n])
  28.         cout << a+"\n";
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement