Submission #345633

#TimeUsernameProblemLanguageResultExecution timeMemory
345633limabeansTrener (COCI20_trener)C++17
55 / 110
2083 ms7940 KiB
#include <bits/stdc++.h> using namespace std; template<typename T> void out(T x) { cout << x << endl; exit(0); } #define watch(x) cout << (#x) << " is " << (x) << endl using ll = long long; const ll mod = 1e9 + 7; void add(ll &x, ll y) { x %= mod; x += y; x %= mod; y %= mod; } // s inside t ? bool inside(string s, string t) { return t.find(s) != std::string::npos; } int n, k; string g[55][1505]; ll dp[55][1505]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>k; for (int i=0; i<n; i++) { for (int j=0; j<k; j++) { cin>>g[i][j]; } } for (int j=0; j<k; j++) { dp[0][j] = 1; } for (int i=1; i<n; i++) { for (int p=0; p<k; p++) { for (int j=0; j<k; j++) { if (inside(g[i-1][p], g[i][j])) { add(dp[i][j], dp[i-1][p]); } } } } ll res = 0; for (int j=0; j<k; j++) { add(res, dp[n-1][j]); } cout<<res<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...