Created
August 15, 2016 17:18
-
-
Save latte0119/0d3d74098771eadcb388dd7b89675b6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
#define int long long | |
typedef vector<int>vint; | |
typedef pair<int,int>pint; | |
typedef vector<pint>vpint; | |
#define rep(i,n) for(int i=0;i<(n);i++) | |
#define reps(i,f,n) for(int i=(f);i<(n);i++) | |
#define all(v) (v).begin(),(v).end() | |
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++) | |
#define pb push_back | |
#define fi first | |
#define se second | |
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;} | |
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;} | |
const int mod=1000000007; | |
int N; | |
char C[222]; | |
int dp[210][210]; | |
inline void add(int &a,int b){ | |
a+=b; | |
if(a>=mod)a-=mod; | |
} | |
signed main(){ | |
cin>>N; | |
rep(i,N)cin>>C[i]; | |
dp[0][0]=1; | |
for(int i=0;i<N;i++){ | |
for(int j=0;j<N;j++){ | |
if(C[i]=='-'){ | |
add(dp[i+1][j],dp[i][j]); | |
} | |
else if(C[i]=='U'){ | |
add(dp[i+1][j],dp[i][j]*j%mod); | |
add(dp[i+1][j+1],dp[i][j]); | |
} | |
else{ | |
if(j)add(dp[i+1][j-1],dp[i][j]*j%mod*j%mod); | |
add(dp[i+1][j],dp[i][j]*j%mod); | |
} | |
} | |
} | |
cout<<dp[N][0]<<endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment