Submission #4172

#TimeUsernameProblemLanguageResultExecution timeMemory
4172pys7293Hexagon travel (kriii1_H)C++98
1 / 1
380 ms1260 KiB
#include <algorithm> #include <cstdio> #include <memory.h> using namespace std; const int MOD = 1000000007; int L, R, M; int C[2][2222][3][3]; int Com[2][2222]; int main(void) { scanf("%d%d%d", &L, &R, &M); C[0][0][2][0] = 1; for (int i = 0; i <= L + R; i++) { for (int j = 0; j <= M; j++) { if (i == 0 && j == 0) continue; int i1 = i & 1; int i2 = 1 - i1; C[i1][j][0][1] = 0; if (j >= 1) (C[i1][j][0][1] += C[i1][j - 1][2][0]) %= MOD; if (i >= 1) (C[i1][j][0][1] += C[i2][j][0][2]) %= MOD; C[i1][j][0][2] = 0; if (j >= 1) (C[i1][j][0][2] += C[i1][j - 1][1][0]) %= MOD; if (i >= 1) (C[i1][j][0][2] += C[i2][j][0][1]) %= MOD; C[i1][j][1][0] = 0; if (j >= 1) (C[i1][j][1][0] += C[i1][j - 1][2][1]) %= MOD; if (i >= 1) (C[i1][j][1][0] += C[i2][j][1][2]) %= MOD; C[i1][j][1][2] = 0; if (j >= 1) (C[i1][j][1][2] += C[i1][j - 1][0][1]) %= MOD; if (i >= 1) (C[i1][j][1][2] += C[i2][j][1][0]) %= MOD; C[i1][j][2][0] = 0; if (j >= 1) (C[i1][j][2][0] += C[i1][j - 1][1][2]) %= MOD; if (i >= 1) (C[i1][j][2][0] += C[i2][j][2][1]) %= MOD; C[i1][j][2][1] = 0; if (j >= 1) (C[i1][j][2][1] += C[i1][j - 1][0][2]) %= MOD; if (i >= 1) (C[i1][j][2][1] += C[i2][j][2][0]) %= MOD; } } for (int i = 0; i <= L + R; i++) { int i1 = i & 1; int i2 = 1 - i1; Com[i1][0] = 1; for (int j = 1; j <= min(i, L); j++) (Com[i1][j] = Com[i2][j - 1] + Com[i2][j]) %= MOD; } int CC = Com[(L + R) & 1][L]; long long RR = (C[(L + R) & 1][M][0][1] + C[(L + R) & 1][M][0][2]) % MOD; (RR *= CC) %= MOD; long long GG = (C[(L + R) & 1][M][1][0] + C[(L + R) & 1][M][1][2]) % MOD; (GG *= CC) %= MOD; long long BB = (C[(L + R) & 1][M][2][0] + C[(L + R) & 1][M][2][1]) % MOD; (BB *= CC) %= MOD; printf("%lld %lld %lld\n", RR, GG, BB); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...