diff options
author | Ta180m | 2019-07-16 12:02:03 -0700 |
---|---|---|
committer | GitHub | 2019-07-16 12:02:03 -0700 |
commit | 22f6d04323669c2c53c23786f904bb7cb7e5a580 (patch) | |
tree | de51e421857cc97565437abd0a33980986ba3548 | |
parent | d396550f98d8bd7dec4005ad198e77cd2649a866 (diff) |
Create bbreeds.cpp
-rw-r--r-- | 2012/November/Gold/bbreeds.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/2012/November/Gold/bbreeds.cpp b/2012/November/Gold/bbreeds.cpp new file mode 100644 index 0000000..9d7a745 --- /dev/null +++ b/2012/November/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; +} |