aboutsummaryrefslogtreecommitdiff
path: root/12/nov/gold/bbreeds.cpp
blob: 9d7a7450c2c97a9acf47a239985c07eb26a43452 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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;
}