Submission #3949

#TimeUsernameProblemLanguageResultExecution timeMemory
3949The_KMJ_GodHexagon travel (kriii1_H)C++98
0 / 1
1500 ms1676 KiB
// 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; }
#Verdict Execution timeMemoryGrader output
Fetching results...