#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 |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
7244 KB |
Output is correct |
2 |
Correct |
26 ms |
7276 KB |
Output is correct |
3 |
Correct |
24 ms |
7224 KB |
Output is correct |
4 |
Correct |
12 ms |
468 KB |
Output is correct |
5 |
Correct |
25 ms |
5104 KB |
Output is correct |
6 |
Correct |
27 ms |
5184 KB |
Output is correct |
7 |
Correct |
13 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
31 ms |
7244 KB |
Output is correct |
6 |
Correct |
26 ms |
7276 KB |
Output is correct |
7 |
Correct |
24 ms |
7224 KB |
Output is correct |
8 |
Correct |
12 ms |
468 KB |
Output is correct |
9 |
Correct |
25 ms |
5104 KB |
Output is correct |
10 |
Correct |
27 ms |
5184 KB |
Output is correct |
11 |
Correct |
13 ms |
468 KB |
Output is correct |
12 |
Correct |
514 ms |
103476 KB |
Output is correct |
13 |
Correct |
524 ms |
103472 KB |
Output is correct |
14 |
Correct |
550 ms |
103568 KB |
Output is correct |
15 |
Correct |
549 ms |
103684 KB |
Output is correct |
16 |
Correct |
166 ms |
2340 KB |
Output is correct |
17 |
Correct |
481 ms |
65668 KB |
Output is correct |
18 |
Correct |
434 ms |
66316 KB |
Output is correct |
19 |
Correct |
460 ms |
65984 KB |
Output is correct |
20 |
Correct |
482 ms |
66244 KB |
Output is correct |
21 |
Correct |
429 ms |
66064 KB |
Output is correct |
22 |
Correct |
172 ms |
2292 KB |
Output is correct |