Submission #223222

#TimeUsernameProblemLanguageResultExecution timeMemory
223222cheehengTrener (COCI20_trener)C++14
110 / 110
152 ms14200 KiB
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9+7; long long dp[55][1505]; char str[55]; string A[55][1505]; map<string, long long> m[55]; int main(){ int N, K; scanf("%d%d", &N, &K); for(int i = 1; i <= N; i ++){ for(int j = 0; j < K; j ++){ memset(str, 0, sizeof(str)); scanf(" %s", str); A[i][j] = string(str); if(i == 1){ dp[i][j] = 1; }else{ string str1 = A[i][j].substr(1); string str2 = A[i][j].substr(0, i-1); //printf("%s %s\n", str1.c_str(), str2.c_str()); dp[i][j] = 0; if(m[i-1].find(str1) != m[i-1].end()){ dp[i][j] += m[i-1][str1]; } if(m[i-1].find(str2) != m[i-1].end() && str1 != str2){ dp[i][j] += m[i-1][str2]; } } dp[i][j] %= MOD; if(m[i].find(A[i][j]) == m[i].end()){ m[i][A[i][j]] = dp[i][j]; }else{ m[i][A[i][j]] += dp[i][j]; } } } long long ans = 0; for(int i = 0; i < K; i ++){ ans += dp[N][i]; } ans %= MOD; printf("%lld", ans); return 0; }

Compilation message (stderr)

trener.cpp: In function 'int main()':
trener.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &N, &K);
     ~~~~~^~~~~~~~~~~~~~~~
trener.cpp:20:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf(" %s", str);
             ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...