Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***
- created: 2022-08-09-21.49.04
- ***/
- #include <bits/stdc++.h>
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- using namespace std;
- using namespace __gnu_pbds;
- template<typename U> using ordered_set=tree<U, null_type,less<U>,rb_tree_tag,tree_order_statistics_node_update>;
- #define ll long long
- #define test int tt; cin>>tt; for(int cs=1;cs<=tt;cs++)
- #define get_lost_idiot return 0
- #define nl '\n'
- ll dp[100005][105];
- ll a[100005],n,m,mod=1e9+7;
- ll solve(ll in,ll val)
- {
- if(val<1 || val>m) return 0;
- if(a[in] && a[in]!=val) return 0;
- if(dp[in][val]!=-1) return dp[in][val];
- if(in==n) return 1;
- ll ans=((solve(in+1,val+1)%mod + solve(in+1,val-1)%mod)%mod+ solve(in+1,val)%mod)%mod;
- return dp[in][val]=ans;
- }
- int main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- cin>>n>>m;
- for(ll i=1; i<=n; i++)
- {
- cin>>a[i];
- }
- memset(dp,-1,sizeof dp);
- ll ans=0;
- for(ll i=1;i<=m;i++)
- {
- ans+=solve(1,i);
- ans%=mod;
- }
- cout<<ans<<nl;
- get_lost_idiot;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement