Submission #219383

#TimeUsernameProblemLanguageResultExecution timeMemory
219383VimmerTrener (COCI20_trener)C++14
110 / 110
136 ms1272 KiB
#include <bits/stdc++.h> //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("-O3") //#pragma GCC optimize("Ofast") //#pragma GCC optimize("fast-math") //#pragma GCC optimize("no-stack-protector") #define F first #define S second #define sz(x) ll(x.size()) #define pb push_back #define N 75005 #define M ll(1e9 + 7) using namespace std; typedef long double ld; typedef long long ll; typedef short int si; map <string, ll> dpl, dp; int main() { ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; vector <string> b(k); dp.clear(); dpl.clear(); for (register int i = 0; i < k; i++) {string str; cin >> str; dpl[str]++;} for (register int i = 1; i < n; i++) { for (register int j = 0; j < k; j++) { string str1, str2; cin >> b[j]; str1 = b[j].substr(0, i); str2 = b[j].substr(1); ll sm = dpl[str1]; if (str1 != str2) sm = (sm + dpl[str2]) % M; dp[b[j]] += sm; dp[b[j]] %= M; } dpl = dp; dp.clear(); } ll ans = 0; for (auto it : dpl) ans = (ans + it.S) % M; cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...