Submission #83352

#TimeUsernameProblemLanguageResultExecution timeMemory
83352charlies_mooMate (COCI18_mate)C++17
100 / 100
453 ms36816 KiB
#include <cstdio> #include <cstring> const int z = 1e9+7; int main() { char s[2001]; scanf("%s", s); int n = strlen(s); int pt[n][n]; pt[0][0] = 1; for (int i = 1; i < n; i++) { pt[i][0] = pt[i][i] = 1; for (int j = 1; j < i; j++) { pt[i][j] = (pt[i-1][j-1] + pt[i-1][j]) % z; } } int c[n][26]; for (int i = 0; i < 26; i++) { c[n-1][i] = 0; } for (int i = n - 2; i >= 0; i--) { for (int j = 0; j < 26; j++) { c[i][j] = c[i+1][j]; } c[i][s[i+1]-'a']++; } int ans[26][26][n]; memset(ans, 0, sizeof(ans)); for (int i = 0; i < n; i++) { for (int j = 0; j < 26; j++) { for (int k = 0; k <= i; k++) { int t = 1ll * pt[i][k] * c[i][j] % z; ans[s[i]-'a'][j][k] = (ans[s[i]-'a'][j][k] + t) % z; } } } int q; scanf("%d", &q); while (q--) { int d; char xy[3]; scanf("%d %s", &d, xy); printf("%d\n", ans[xy[0]-'a'][xy[1]-'a'][d-2]); } return 0; }

Compilation message (stderr)

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