Submission #1124093

#TimeUsernameProblemLanguageResultExecution timeMemory
1124093ezzzayTrener (COCI20_trener)C++20
55 / 110
2094 ms3560 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second #define pb push_back #define pii pair<int,int> const int N = 2e6+5; const int MOD = 1e9+7; ll ans[55][1505]; string str[55][1505]; bool issubstr(string a, string b){ int n=a.length(), m=b.length(); for(int i=0; i<m-n+1; i++){ if(b.substr(i, n) == a) return 1; } return 0; } int main(){ int n, k; cin >> n >> k; for(int i=0; i<k; i++){ ans[0][i]=1; } for(int i=0; i<n; i++){ for(int j=0; j<k; j++){ cin >> str[i][j]; if(i > 0){ for(int h=0; h<k; h++){ if(issubstr(str[i-1][h], str[i][j])){ ans[i][j]=(ans[i][j]+ans[i-1][h])%MOD; } } } } } ll anss=0; for(int i=0; i<k; i++){ anss=(anss+ans[n-1][i])%MOD; } cout << anss; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...