Submission #845244

#TimeUsernameProblemLanguageResultExecution timeMemory
845244vjudge1Trener (COCI20_trener)C++17
55 / 110
2040 ms780 KiB
#include <iostream> #include <algorithm> using namespace std; int main(){ int n, k; int64_t mod = 1000000007, *scores, *newscores; string *surnames, *newsurnames; cin >> n >> k; surnames = new string[k]; newsurnames = new string[k]; scores = new int64_t[k]; newscores = new int64_t[k]; for (int i = 0; i < k; i++){ cin >> surnames[i]; scores[i] = 1; } for (int newlen = 2; newlen <= n; newlen++){ for (int i = 0; i < k; i++){ cin >> newsurnames[i]; newscores[i] = 0; for (int j = 0; j < k; j++){ if (newsurnames[i][0] + surnames[j] == newsurnames[i] || surnames[j] + newsurnames[i][newlen - 1] == newsurnames[i]){ newscores[i] = (newscores[i] + scores[j]) % mod; } } } for (int i = 0; i < k; i++){ surnames[i] = newsurnames[i]; scores[i] = newscores[i]; } } int64_t total = 0; for (int i = 0; i < k; i++){ total = (total + scores[i]) % mod; } cout << total; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...