-
Notifications
You must be signed in to change notification settings - Fork 189
Expand file tree
/
Copy patht.cc
More file actions
25 lines (23 loc) · 624 Bytes
/
Copy patht.cc
File metadata and controls
25 lines (23 loc) · 624 Bytes
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
// https://atcoder.jp/contests/dp/tasks/dp_t
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 3000, M = 1e9 + 7;
ll dp[N + 1][N + 1];
int main() {
cin.tie(0), ios::sync_with_stdio(0);
int n;
string s;
cin >> n >> s;
dp[1][1] = 1;
for (int i = 1; i < n; i++)
if (s[i - 1] == '<')
for (int k = 1; k <= i + 1; k++)
(dp[i + 1][k] = dp[i + 1][k - 1] + dp[i][k - 1]) %= M;
else
for (int k = 1; k <= i + 1; k++)
(dp[i + 1][k] = dp[i + 1][k - 1] + dp[i][i] - dp[i][k - 1]) %= M;
ll ans = dp[n][n];
if (ans < 0) ans += M;
cout << ans << '\n';
}