# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
8152 | paulsohn | Hexagon travel (kriii1_H) | C++98 | 0 ms | 32768 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>
enum{red_green, red_blue, green_blue, green_red, blue_red, blue_green};
int L, R, M, movement[4001][2001][6] = { 0 }; //movement[L+R][M][color_forward]
int fact(int x){
if (x == 0) return 1;
return x*fact(x - 1);
}
int main(){
int comb;
scanf("%d %d %d", &L, &R, &M);
movement[0][0][4] = 1;
for (int m = 0; m <= M; ++m){
for (int t = 0; t <= L + R; ++t){
for (int i = 0; i < 3; ++i){
if (movement[t][m][2 * i] >= 1000000007)
movement[t][m][2*i] %= 1000000007;
if (movement[t][m][2 * i+1] >= 1000000007)
movement[t][m][2*i+1] %= 1000000007;
if (t < L + R){
movement[t + 1][m][2 * i] += movement[t][m][2 * i + 1];
movement[t + 1][m][2 * i + 1] += movement[t][m][2 * i];
}
if (m < M){
movement[t][m + 1][2 * i] += movement[t][m][(2 * i + 4) % 6];
movement[t][m + 1][2 * i + 1] += movement[t][m][(2 * i + 3) % 6];
}
}
}
}
comb = fact(L + R) / fact(L) / fact(R);
for (int i = 0; i < 3; ++i){
printf("%d\n", (comb * (movement[L + R][M][2 * i] + movement[L + R][M][2 * i + 1]) % 1000000007) % 1000000007);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |