# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
238564 | vankata | Trener (COCI20_trener) | C++14 | 18 ms | 1408 KiB |
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;
const int MAXN = 2048;
const int MOD = (int)(1e9+7);
map<string,int>mp;
long long n,k;
bool cmp(string a,string b)
{
for(size_t i=0;i<a.size();i++)
{
if(a[i]!=b[i])return false;
}return true;
}
void read()
{
int i,j,l;
long long ans = 0;
cin>>n>>k;
string s,t,q;
int lm=0;
for(i=0;i<n;i++)
{
for(j=0;j<k;j++)
{
cin>>s;
if(!i){mp[s]++;continue;}
t="";
q="";
for(l=0;l<s.size();l++)
{
if(l>0)q+=s[l];
if(l!=s.size()-1)t+=s[l];
}
mp[s]+=mp[q];
if(!cmp(q,t))mp[s]+=mp[t];
mp[s]%=MOD;
if(i==n-1)
{
ans+=mp[s];
ans%=MOD;
}
}
}
if(n==1)
{
cout<<k<<endl;
return ;
}
cout<<ans<<endl;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
read();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |