Submission #142524

#TimeUsernameProblemLanguageResultExecution timeMemory
142524KCSCMate (COCI18_mate)C++14
100 / 100
395 ms24568 KiB
#include <bits/stdc++.h> using namespace std; const int DIM = 2005; const int SIGMA = 26; const int MOD = 1000000007; char str[DIM], aux[3]; int dp[DIM][SIGMA][SIGMA], cnt[DIM][SIGMA], cmb[DIM][DIM]; int main(void) { // freopen("mate.in", "r", stdin); // freopen("mate.out", "w", stdout); scanf("%s", str + 1); int n = strlen(str + 1); for (int i = 0; i <= n; ++i) { cmb[i][0] = 1; for (int j = 1; j <= i; ++j) cmb[i][j] = (cmb[i - 1][j - 1] + cmb[i - 1][j]) % MOD; } for (int i = 1; i <= n; ++i) for (int j = i + 1; j <= n; ++j) ++cnt[i][str[j] - 'a']; for (int i = 1; i <= n; ++i) for (int j = 0; j < i; ++j) for (int k = 0; k < 26; ++k) dp[j + 2][str[i] - 'a'][k] = (1LL * cmb[i - 1][j] * cnt[i][k] + dp[j + 2][str[i] - 'a'][k]) % MOD; int q; scanf("%d", &q); while (q--) { int x; scanf("%d %s", &x, aux + 1); printf("%d\n", dp[x][aux[1] - 'a'][aux[2] - 'a']); } return 0; }

Compilation message (stderr)

mate.cpp: In function 'int main()':
mate.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", str + 1);
     ~~~~~^~~~~~~~~~~~~~~
mate.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &q);
     ~~~~~^~~~~~~~~~
mate.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %s", &x, aux + 1);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...