Submission #530941

#TimeUsernameProblemLanguageResultExecution timeMemory
530941Servus2022Trener (COCI20_trener)C++14
110 / 110
298 ms26104 KiB
#include <bits/stdc++.h> using namespace std; constexpr int MOD = 1e9 + 7; int N, K; map <string, int> dp; map <string, int> lg; void Read () { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> N >> K; } void Solve () { for (int i = 1; i <= N; ++ i ) { for (int j = 1; j <= K; ++ j ) { string S; cin >> S; if (i == 1) { dp[S] ++; lg[S] = 1; continue; } string primul, aldoilea; for (int k = 0; k < S.size()-1; ++ k ) { primul.push_back(S[k]); aldoilea.push_back(S[k+1]); } if (primul == aldoilea) { if (lg[primul] == i-1) { lg[S] = i; dp[S] = (dp[S] + dp[primul]) % MOD; } continue; } if (lg[primul] == i-1) { lg[S] = i; dp[S] = (dp[S] + dp[primul]) % MOD; } if (lg[aldoilea] == i-1) { lg[S] = i; dp[S] = (dp[S] + dp[aldoilea]) % MOD; } } } int ans = 0; for (auto it : dp) { if (lg[it.first] == N) ans = (ans + it.second) % MOD; } cout << ans << '\n'; } int main () { Read(); Solve(); return 0; }

Compilation message (stderr)

trener.cpp: In function 'void Solve()':
trener.cpp:30:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             for (int k = 0; k < S.size()-1; ++ k ) {
      |                             ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...