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>
#define f(i,j,n) for(int i = j; i < n; ++i)
#define sz(s) (int) (s.size())
using namespace std;
typedef long long ll;
const int N = 3e3 + 20;
const ll mod = 1e9 + 7;
ll sum(ll a,ll b){
return (a+b)%mod;
}
ll n,k;
map<deque<char>,ll> dp;
deque<char> s;
int main(){
cin >> n >> k;
f(i,1,n+1){
f(j,1,k+1){
s.resize(i);
f(r,0,i) cin >> s[r];
if(i == 1){
dp[s] = sum(dp[s],1LL); continue;
}
deque<char> ps = s,ss = s;
ss.pop_front();
ps.pop_back();
dp[s] = sum(dp[ss],dp[s]);
if(ss != ps) dp[s] = sum(dp[ps],dp[s]);
}
}
ll ans = 0;
for(auto [it,vl] : dp){
if(sz(it) == n) ans = sum(ans,vl);
}
cout << ans << 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... |