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>
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(h[s] >= MOD) h[s] -= MOD;
if(i == n-1) ans += curr;
if(ans >= MOD) ans -= MOD;
}
cout<<ans<<'\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |