#include<bits/stdc++.h>
using namespace std;
unordered_map<string,int>h;
const int MOD = 1e9 + 7;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
long long n,k,i,j,curr,ans = 0;
string s,sub1,sub2;
cin>>n>>k;
for(i = 0; i < n; i++)
for(j = 0; j < k; j++)
{
cin>>s;
sub1 = s.substr(0,i);
sub2 = s.substr(1,i);
curr = h[sub1];;
if(sub1 != sub2) curr += h[sub2];
if(curr >= MOD) curr -= MOD;
if(i==0) curr++;
h[s] += curr;
if(i == n-1) ans += curr;
if(ans >= MOD) ans -= MOD;
}
cout<<ans<<'\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
1408 KB |
Output is correct |
2 |
Correct |
9 ms |
1408 KB |
Output is correct |
3 |
Correct |
8 ms |
1408 KB |
Output is correct |
4 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
9 ms |
1408 KB |
Output is correct |
6 |
Correct |
9 ms |
1408 KB |
Output is correct |
7 |
Correct |
8 ms |
1408 KB |
Output is correct |
8 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |