This commit is contained in:
HuangHai
2025-08-30 18:35:01 +08:00
commit 1f397eca87
6258 changed files with 1487241 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
#include <bits/stdc++.h>
using namespace std;
int n;
int res;
stack<char> stk;
bool check(string t) {
stack<char>().swap(stk);
for (int i = t.size() - 1; i >= 0; i--) {
if (!stk.empty() && stk.top() == '}' && t[i] == '{')
stk.pop();
else
stk.push(t[i]);
}
return stk.size() == 0;
}
void dfs(int u, string t) {
if (u == 2 * n + 1) {
if (check(t)) res++;
return;
}
dfs(u + 1, t + "{");
dfs(u + 1, t + "}");
}
int main() {
cin >> n;
dfs(1, "");
cout << res << endl;
return 0;
}