제출 #142513

#제출 시각아이디문제언어결과실행 시간메모리
142513KCSCMate (COCI18_mate)C++14
0 / 100
387 ms15180 KiB
// Credits to Mihaela Cismaru pentru ca m-a ajutat sa corectez penalitatea asta
#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][SIGMA];

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;
}

컴파일 시 표준 에러 (stderr) 메시지

mate.cpp: In function 'int main()':
mate.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", str + 1);
     ~~~~~^~~~~~~~~~~~~~~
mate.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &q);
     ~~~~~^~~~~~~~~~
mate.cpp:33: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...