# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3945 | The_KMJ_God | Hexagon travel (kriii1_H) | C++98 | 0 ms | 32768 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// 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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |