Submission #845315

#TimeUsernameProblemLanguageResultExecution timeMemory
845315vjudge1Trener (COCI20_trener)C++17
0 / 110
10 ms1884 KiB
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<map<string, int>> cnt(N); for (int i = 0;i < N; ++i) { for (int j = 0;j < K; ++j) { string s; cin >> s; cnt[i][s] += 1; } } if (N == 1) { cout << K << '\n'; return 0; } int64_t mod = 1e9+7; map<string, int64_t> dp; for (int i = N-1;i >= 0; --i) { for (auto [s, c] : cnt[i]) { if (i == N-1) { dp[s] = c; } string a = s; string b = s; reverse(b.begin(), b.end()); a.pop_back(); b.pop_back(); reverse(b.begin(), b.end()); dp[a] += c * dp[s]; if (a != b) dp[b] += c * dp[s]; dp[a] %= mod; dp[b] %= mod; } } string s = ""; int64_t ans = dp[s]; cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...