aboutsummaryrefslogtreecommitdiff
path: root/12/nov/gold/bbreeds.cpp
diff options
context:
space:
mode:
Diffstat (limited to '12/nov/gold/bbreeds.cpp')
-rw-r--r--12/nov/gold/bbreeds.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/12/nov/gold/bbreeds.cpp b/12/nov/gold/bbreeds.cpp
new file mode 100644
index 0000000..9d7a745
--- /dev/null
+++ b/12/nov/gold/bbreeds.cpp
@@ -0,0 +1,14 @@
+#include <iostream>
+#include <string>
+using namespace std;
+
+int main() {
+ string S; cin >> S;
+ int x = 0, DP[1005] = { 1 };
+ for (auto c : S) {
+ if (c == '(') for (x++, int i = x; i > 0; i--) DP[i] = (DP[i - 1] + DP[i]) % 2012;
+ else for (x--, int i = 0; i <= x; i++) DP[i] = (DP[i] + DP[i + 1]) % 2012;
+ DP[x + 1] = 0;
+ }
+ cout << DP[0] << endl;
+}