This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
#define int long long
#define ll long long
#define y1 YONE
#define free freeee
#define lcm llcm
typedef unsigned long long ull;
using namespace std;
const int N=2e3+5,M=1e6+3;
int a[N],n,k,b[N],dp[N][N];
bool vis[N][N];
int rec(int i,int mask){
if (__builtin_popcount(mask)!=b[i]) return 0;
if (i==n-k+1) return 1;
if (vis[i][mask]) return dp[i][mask];
vis[i][mask]=true;
return dp[i][mask]=(rec(i+1,mask/2)+rec(i+1,mask/2+(1<<(k-1))))%M;
}
int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin>>n>>k;
for (int i=1;i<=n-k+1;i++) cin>>b[i];
for (int i=0;i<(1<<k);i++) dp[0][0]=(dp[0][0]+rec(1,i))%M;
cout<<dp[0][0]<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |