# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
482197 | rainboy | Trener (COCI20_trener) | C11 | 1371 ms | 6456 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <string.h>
#define N 50
#define K 1500
#define MD 1000000007
int main() {
static char cc[N][K][N + 1];
static int dp[N][K];
int n, k, h, h_, i, ans;
scanf("%d%d", &n, &k);
for (i = 0; i < n; i++)
for (h = 0; h < k; h++)
scanf("%s", cc[i][h]);
for (h = 0; h < k; h++)
dp[0][h] = 1;
for (i = 0; i + 1 < n; i++)
for (h = 0; h < k; h++)
for (h_ = 0; h_ < k; h_++)
if (strncmp(cc[i + 1][h_], cc[i][h], i + 1) == 0 || strncmp(cc[i + 1][h_] + 1, cc[i][h], i + 1) == 0)
dp[i + 1][h_] = (dp[i + 1][h_] + dp[i][h]) % MD;
ans = 0;
for (h = 0; h < k; h++)
ans = (ans + dp[n - 1][h]) % MD;
printf("%d\n", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |