-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplace-of-sign.cpp
56 lines (46 loc) · 1.15 KB
/
place-of-sign.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
ll dp[5001][5001];
int main() {
// cout << fixed << setprecision(10);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
string s;
cin >> n >> s;
memset(dp, 0, sizeof dp);
for (int j = 1; j < n + 1; j++) {
dp[1][j] = 1;
}
for (int i = 2; i < n + 1; i++) {
if (s[i - 2] == '<') {
for (int j = 1; j < n + 1; j++) {
dp[i][j] = (dp[i][j - 1] + dp[i - 1][j - 1]) % mod;
}
}
else if (s[i - 2] == '>') {
for (int j = n; j; j--) {
dp[i][j] = (dp[i][j + 1] + dp[i - 1][j + 1]) % mod;
}
}
else {
for (int j = 1; j < n + 1; j++) {
dp[i][j] = dp[i - 1][j];
}
}
}
ll ans = 0;
for (int j = 1; j < n + 1; j++) {
ans += dp[n][j];
}
cout << ans % mod;
}