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;
typedef long long ll;
//au majko sta odradi ova unordered mapa
//ekstra bas lep zadatak - uradjen
// :))))
int n;
int k;
ll sol;
ll mod;
vector<int> spusta[100005];
ll dp[100005];
vector<string> b[55];
unordered_map<string,ll> mp;
set<string> vec;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cerr.tie(0);
cin >> n >> k;
mod = (ll)(1e9)+7;
sol = 0;
for(int i=1;i<=n;i++)
{
for(int qq=1;qq<=k;qq++)
{
string s;
cin >> s;
if(s.size()==1) mp[s]++;
else
{
string s1 = s.substr(0,i-1);
string s2 = s.substr(1,i-1);
if(s1!=s2) mp[s] = ((mp[s] + mp[s.substr(0,i-1)])%mod + mp[s.substr(1,i-1)])%mod;
else mp[s] = (mp[s] + mp[s1])%mod;
if(i==n) vec.insert(s);
}
}
}
for(string ss : vec) sol = (sol+mp[ss])%mod;
cout << sol;
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... |