Submission #3733

# Submission time Handle Problem Language Result Execution time Memory
3733 2013-08-31T07:56:17 Z cki86201 Hexagon travel (kriii1_H) C++
0 / 1
0 ms 1388 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][2020],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",(int)((long long)t*C)%T);
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1388 KB Output is correct
2 Correct 0 ms 1388 KB Output is correct
3 Correct 0 ms 1388 KB Output is correct
4 Correct 0 ms 1388 KB Output is correct
5 Incorrect 0 ms 1388 KB Output isn't correct
6 Halted 0 ms 0 KB -