Submission #845258

#TimeUsernameProblemLanguageResultExecution timeMemory
845258vjudge1Trener (COCI20_trener)C++14
110 / 110
251 ms22324 KiB
#include <bits/stdc++.h> #define int long long int MOD = 1e9+7; using namespace std; void solve(void){ int n, k; cin >> n >> k; vector<vector<string>> bruh(n, vector<string>(k)); for(int i=0; i<n; i++) for(int g=0; g<k; g++) cin >> bruh[i][g]; map<string, int> hmmm; for(int g=0; g<k; g++){ hmmm[ bruh[n-1][g] ] = 1; } for(int i=n-1; i>0; i--){ for(int g=0; g<k; g++){ string ss = bruh[i][g]; string fr = ss.substr(0, i); string bc = ss.substr(1, i); hmmm[fr] += hmmm[ss]; hmmm[fr] = hmmm[fr]%MOD; if( fr != bc ){ hmmm[bc] = (hmmm[bc] + hmmm[ss] )%MOD; } } } int cnt = 0; for(int i=0; i<k; i++){ cnt += hmmm[bruh[0][i]]; cnt%=MOD; } cout << cnt << "\n"; } signed main(){ int t=1; // cin >> t; while(t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...