Submission #238435

#TimeUsernameProblemLanguageResultExecution timeMemory
238435stev2005Trener (COCI20_trener)C++17
55 / 110
2080 ms9720 KiB
#include<iostream> #include<string> using namespace std; const int mod=1000000007; int n,k,dp[62][2048]; string s[62][2048]; void read() { cin>>n>>k; for(int i=0;i<n;i++) for(int j=0;j<k;j++) { cin>>s[i][j]; } } void solve() { for(int i=0;i<k;i++) dp[0][i]=1; int rez; for(int i=1;i<n;i++) for(int j=0;j<k;j++) for(int p=0;p<k;p++) { rez=(int)s[i][j].find(s[i-1][p]); ///cout<<rez<<' '<<s[i][j]<<' '<<s[i-1][p]<<endl; if(rez>-1)dp[i][j]=(dp[i-1][p]%mod+dp[i][j]%mod)%mod; } int ans=0,pos=n-1; for(int i=0;i<k;i++) ans=(dp[pos][i]%mod+ans%mod)%mod; cout<<ans<<endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); read(); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...