답안 #3949

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3949 2013-08-31T09:38:37 Z The_KMJ_God Hexagon travel (kriii1_H) C++
0 / 1
1500 ms 1676 KB
// problem H


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<memory.h>
using namespace std;

class node {
public:
	int blue,red,green;
	bool check;
	void put( int a, int b, int c) {
		blue=a; red=b; green=c; check=false;
	}
	node ( int a, int b, int c) {
		blue=a; red=b; green=c; check=false;
	}
	node () {
		blue=0; red=0; green=0; check=false;
	}
	void operator+=(const node &in) {
		blue=(blue+in.blue)%1000000007;
		red=(red+in.red)%1000000007;
		green=(green+in.green)%1000000007;
	}
};

//node dp[4000][2000][2][3];
int g[3][2]={1,2,2,0,0,1};

node f( int x, int direction, int l, int r, int m ) {
	if ( l==0 && r==0 && m==0 ) {
		node e;
		switch(x) {
			case 0: e.put(1,0,0); break;
			case 1: e.put(0,1,0); break;
			case 2: e.put(0,0,1); break;
		}
		return e;
	}
	//if ( dp[l+r][m][direction][x].check ) return dp[l+r][m][direction][x];
	//dp[l+r][m][direction][x].check=true;

	node e;
	int i,j,tmp=(direction+1)%2;
	if ( m>0 ) e+=f(g[x][direction],direction,l,r,m-1);
	if ( l>0 ) e+=f(x,tmp,l-1,r,m);
	if ( r>0 ) e+=f(x,tmp,l,r-1,m);

	return /*dp[l+r][m][direction][x]=*/e;
}

int main() {
	int i,j,L,R,M;
	scanf("%d %d %d",&L,&R,&M);
	node k=f(0,0,L,R,M);
	printf("%d\n",k.red);
	printf("%d\n",k.green);
	printf("%d\n",k.blue);
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1676 KB Output is correct
2 Correct 0 ms 1676 KB Output is correct
3 Correct 0 ms 1676 KB Output is correct
4 Correct 0 ms 1676 KB Output is correct
5 Execution timed out 1500 ms 1672 KB Program timed out
6 Halted 0 ms 0 KB -