Submission #3738

# Submission time Handle Problem Language Result Execution time Memory
3738 2013-08-31T08:01:14 Z cki86201 Hexagon travel (kriii1_H) C++
1 / 1
180 ms 1404 KB
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
using namespace std;

const int T = 1e9+7;
int Dp[2][4040][3][3];
int R,M;

int f()
{
	int i,j;
	for(i=0;i<=R;i++){Dp[0][i][0][2]=1-(i%2);Dp[0][i][0][1]=i%2;}
	for(i=1;i<=M;i++){
		Dp[1][0][0][1]=Dp[1][0][0][2]=Dp[1][0][1][0]=Dp[1][0][1][2]=Dp[1][0][2][0]=Dp[1][0][2][1]=0;
		if(i%3==0)Dp[1][0][0][2]=1;
		else if(i%3==1)Dp[1][0][2][1]=1;
		else Dp[1][0][1][0]=1;
		for(j=1;j<=R;j++){
			Dp[1][j][0][1]=(Dp[1][j-1][0][2]+Dp[0][j][2][0])%T;
			Dp[1][j][0][2]=(Dp[1][j-1][0][1]+Dp[0][j][1][0])%T;
			Dp[1][j][1][0]=(Dp[1][j-1][1][2]+Dp[0][j][2][1])%T;
			Dp[1][j][1][2]=(Dp[1][j-1][1][0]+Dp[0][j][0][1])%T;
			Dp[1][j][2][0]=(Dp[1][j-1][2][1]+Dp[0][j][1][2])%T;
			Dp[1][j][2][1]=(Dp[1][j-1][2][0]+Dp[0][j][0][2])%T;
		}
		for(j=0;j<=R;j++){
			Dp[0][j][0][1]=Dp[1][j][0][1];
			Dp[0][j][0][2]=Dp[1][j][0][2];
			Dp[0][j][1][0]=Dp[1][j][1][0];
			Dp[0][j][1][2]=Dp[1][j][1][2];
			Dp[0][j][2][0]=Dp[1][j][2][0];
			Dp[0][j][2][1]=Dp[1][j][2][1];
		}
	}
}

int read(int x)
{
	return (Dp[0][R][x][0]+Dp[0][R][x][1]+Dp[0][R][x][2])%T;
}

int tmp[2][4020],l,r;
int nCr()
{
	int i,j;
	tmp[0][0]=1;
	for(i=1;i<=l+r;i++){
		tmp[1][0]=1;
		for(j=1;j<=i;j++){
			tmp[1][j]=(tmp[0][j]+tmp[0][j-1])%T;
		}
		for(j=0;j<=i;j++)tmp[0][j]=tmp[1][j];
	}
	return tmp[0][l];
}

int main()
{
	scanf("%d%d%d",&l,&r,&M);
	R=l+r;
	f();
	int C = nCr();
	for(int i=2;i>=0;i--){
		int t=read(i);
		printf("%d\n",((long long)t*C)%T);
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1404 KB Output is correct
2 Correct 0 ms 1404 KB Output is correct
3 Correct 0 ms 1404 KB Output is correct
4 Correct 0 ms 1404 KB Output is correct
5 Correct 0 ms 1404 KB Output is correct
6 Correct 8 ms 1404 KB Output is correct
7 Correct 0 ms 1404 KB Output is correct
8 Correct 0 ms 1404 KB Output is correct
9 Correct 8 ms 1404 KB Output is correct
10 Correct 180 ms 1404 KB Output is correct
11 Correct 100 ms 1404 KB Output is correct
12 Correct 60 ms 1404 KB Output is correct
13 Correct 16 ms 1404 KB Output is correct
14 Correct 48 ms 1404 KB Output is correct
15 Correct 48 ms 1404 KB Output is correct
16 Correct 16 ms 1404 KB Output is correct
17 Correct 56 ms 1404 KB Output is correct
18 Correct 56 ms 1404 KB Output is correct
19 Correct 20 ms 1404 KB Output is correct
20 Correct 28 ms 1404 KB Output is correct