Submission #845447

#TimeUsernameProblemLanguageResultExecution timeMemory
845447vjudge1Trener (COCI20_trener)C++17
0 / 110
5 ms1368 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int MOD = 1e9+7; int32_t main(){ int n,k; cin>>n>>k; vector<vector<int>> dp(n,vector<int>(k,-1)); vector<vector<string>> arr(n,vector<string>(k)); for (int i = 0; i < n; i++){ for (int j = 0; j < k; j++){ cin>>arr[i][j]; } } function<int(int,int)> f;f=[&](int node, int flag)->int{ if (node==n-1) return 1ll; if (dp[node][flag]!=-1) return dp[node][flag]; dp[node][flag]=0; for (int i = 0; i < k; i++){ bool boolean=false; for (int j = 0; j+node<n; j++){ if (arr[node+1][i].substr(j,node+1)==arr[node][flag]){ boolean=true; break; } } if (boolean){ dp[node][flag]+=f(node+1,i); dp[node][flag]%=MOD; } } return dp[node][flag]; }; int ans = 0; for (int i = 0; i < k; i++){ ans+=f(0,i); ans%=MOD; } cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...