Submission #223217

#TimeUsernameProblemLanguageResultExecution timeMemory
223217dantoh000Trener (COCI20_trener)C++14
55 / 110
2086 ms6264 KiB
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int n,k; int dp[2][1505]; string a[55][1505]; bool can(string a, string b){ return b.substr(1) == a || b.substr(0,b.size()-1) == a; } int main(){ scanf("%d%d",&n,&k); for (int i = 1; i <= n; i++){ for (int j = 1; j <= k; j++){ cin >> a[i][j]; } } for (int i = 1; i <= k; i++) dp[n&1][i] = 1; for (int i = n-1; i >= 1; i--){ for (int j = 1; j <= k; j++){ dp[i&1][j] = 0; for (int j2 = 1; j2 <= k; j2++){ if (can(a[i][j],a[i+1][j2])){ dp[i&1][j] += dp[1-i&1][j2]; dp[i&1][j] %= mod; } } } } int sum = 0; for (int i = 1; i <= k; i++) { sum += dp[1][i]; sum %= mod; } printf("%d",sum); }

Compilation message (stderr)

trener.cpp: In function 'int main()':
trener.cpp:23:39: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
                     dp[i&1][j] += dp[1-i&1][j2];
                                      ~^~
trener.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&k);
     ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...