Submission #1119652

#TimeUsernameProblemLanguageResultExecution timeMemory
1119652ezzzayTrener (COCI20_trener)C++14
0 / 110
109 ms127308 KiB
#include<bits/stdc++.h> using namespace std; #define itn long long #define int long long #define ff first #define ss second #define pb push_back const int N=2003; string a[N][N]; const int mod=1e9+7; map<string,int>dp; signed main(){ int n,k; cin>>n>>k; for(int i=1;i<=n;i++){ for(int j=1;j<=k;j++)cin>>a[i][j]; } for(int i=1;i<=k;i++){ dp[a[1][i]]++; } for(int i=2;i<=n;i++){ for(int j=1;j<=k;j++){ string x=a[i][j]; string y=x; y.pop_back(); dp[x]+=dp[y]; if(x.substr(1,i-1)!=y)dp[x]+=dp[x.substr(1,i-1)]; dp[x]%=mod; } } int ans=0; for(int i=1;i<=k;i++){ ans+=dp[a[n][i]]; ans%=mod; } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...