#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9 + 7;
signed main()
{
int n,k;
cin>>n>>k;
map<string,int> ans;
int fin_ans=0,iv = (mod+1)/2;
for (int a=1;a<=n;a++)
for (int b=0;b<k;b++)
{
string s;
cin>>s;
if (a==1)
{
ans[s]=1;
continue;
}
int x=0;
string s1=s.substr(0,a-1),s2=s.substr(1,a-1);
if (ans.find(s1)!=ans.end())
x+=ans[s1];
if (ans.find(s2)!=ans.end())
x+=ans[s2];
x%=mod;
if (s1==s2)
x=x*iv%mod;
ans[s]=x;
if (a==n)
fin_ans+=x,fin_ans%=mod;
}
cout<<fin_ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
860 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |