# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
544445 | rainboy | Jump (BOI06_jump) | C11 | 8 ms | 4144 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>
#define N 100
#define L 100
void add(int *aa, int *bb) {
int i;
for (i = 0; i < L; i++)
aa[i] += bb[i];
for (i = 0; i < L; i++)
if (aa[i] >= 10) {
if (i + 1 < L)
aa[i + 1] += aa[i] / 10;
aa[i] %= 10;
}
}
int main() {
static int dp[N][N][L];
int n, i, j;
scanf("%d", &n);
dp[0][0][0] = 1;
for (i = 0; i < n; i++)
for (j = 0; j < n; j++) {
int a;
scanf("%d", &a);
if (a == 0)
continue;
if (i + a < n)
add(dp[i + a][j], dp[i][j]);
if (j + a < n)
add(dp[i][j + a], dp[i][j]);
}
i = L - 1;
while (i > 0 && dp[n - 1][n - 1][i] == 0)
i--;
while (i >= 0)
printf("%d", dp[n - 1][n - 1][i--]);
printf("\n");
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |