Submission #4172

# Submission time Handle Problem Language Result Execution time Memory
4172 2013-09-03T03:46:04 Z pys7293 Hexagon travel (kriii1_H) C++
1 / 1
380 ms 1260 KB
#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 time Memory Grader output
1 Correct 0 ms 1260 KB Output is correct
2 Correct 0 ms 1260 KB Output is correct
3 Correct 0 ms 1260 KB Output is correct
4 Correct 0 ms 1260 KB Output is correct
5 Correct 0 ms 1260 KB Output is correct
6 Correct 4 ms 1260 KB Output is correct
7 Correct 0 ms 1260 KB Output is correct
8 Correct 0 ms 1260 KB Output is correct
9 Correct 16 ms 1260 KB Output is correct
10 Correct 380 ms 1260 KB Output is correct
11 Correct 220 ms 1260 KB Output is correct
12 Correct 116 ms 1260 KB Output is correct
13 Correct 40 ms 1260 KB Output is correct
14 Correct 116 ms 1260 KB Output is correct
15 Correct 112 ms 1260 KB Output is correct
16 Correct 36 ms 1260 KB Output is correct
17 Correct 96 ms 1260 KB Output is correct
18 Correct 120 ms 1260 KB Output is correct
19 Correct 44 ms 1260 KB Output is correct
20 Correct 68 ms 1260 KB Output is correct