Submission #1119647

#TimeUsernameProblemLanguageResultExecution timeMemory
1119647ezzzayTrener (COCI20_trener)C++14
55 / 110
2074 ms131744 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]; int dp[N][N]; const int mod=1e9+7; 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[1][i]=1; for(int i=2;i<=n;i++){ for(int j=1;j<=k;j++){ string x=a[i][j]; for(int p=1;p<=k;p++){ string y=a[i-1][p]; if(x.substr(0,i-1)==y or x.substr(1,i-1)==y){ dp[i][j]+=dp[i-1][p]; dp[i][j]%=mod; } } } } int ans=0; for(int i=1;i<=k;i++){ ans+=dp[n][i]; ans%=mod; } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...