#include<stdio.h>
#include<memory.h>
#define md 1000000007
typedef long long ll;
int l, r, m, ty;
ll cmb[2][2222], dy[2][2222][6], t;
// loop type : 0=RGB, 1=RBG, 2=GBR, 3=GRB, 4=BRG, 5=BGR
int main(){
int i, j, k, x;
scanf("%d%d%d", &l, &r, &m);
for(i=0; i<=l+r; i++){
for(j=0; j<=r; j++){
if(i<j)break;
if(i==j || !j)cmb[1-ty][j]=1;
else{
cmb[1-ty][j]=cmb[ty][j]+cmb[ty][j-1];
if(cmb[1-ty][j]>=md)cmb[1-ty][j]-=md;
}
}
ty=1-ty;
}
t=cmb[ty][r], ty=0;
dy[ty][m][4]=1;
for(i=l+r+m; i>0; i--){
memset(dy[1-ty],0,sizeof(dy[1-ty]));
for(j=m; j>=0; j--){
if(i<j)continue;
for(k=0; k<6; k++){
if(i-j>0){
dy[1-ty][j][k^1]+=dy[ty][j][k];
if(dy[1-ty][j][k^1]>=md)dy[1-ty][j][k^1]-=md;
}
if(j>0){
if(k%2)x=(k+4)%6;
else x=(k+2)%6;
dy[1-ty][j-1][x]+=dy[ty][j][k];
if(dy[1-ty][j-1][x]>=md)dy[1-ty][j-1][x]-=md;
}
}
}
ty=1-ty;
}
for(i=0; i<3; i++)printf("%lld\n", t*(dy[ty][0][2*i]+dy[ty][0][2*i+1])%md);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1328 KB |
Output is correct |
2 |
Correct |
0 ms |
1328 KB |
Output is correct |
3 |
Correct |
0 ms |
1328 KB |
Output is correct |
4 |
Correct |
0 ms |
1328 KB |
Output is correct |
5 |
Correct |
0 ms |
1328 KB |
Output is correct |
6 |
Correct |
20 ms |
1328 KB |
Output is correct |
7 |
Correct |
0 ms |
1328 KB |
Output is correct |
8 |
Correct |
104 ms |
1328 KB |
Output is correct |
9 |
Correct |
32 ms |
1328 KB |
Output is correct |
10 |
Correct |
576 ms |
1328 KB |
Output is correct |
11 |
Correct |
368 ms |
1328 KB |
Output is correct |
12 |
Correct |
184 ms |
1328 KB |
Output is correct |
13 |
Correct |
72 ms |
1328 KB |
Output is correct |
14 |
Correct |
232 ms |
1328 KB |
Output is correct |
15 |
Correct |
208 ms |
1328 KB |
Output is correct |
16 |
Correct |
76 ms |
1328 KB |
Output is correct |
17 |
Correct |
156 ms |
1328 KB |
Output is correct |
18 |
Correct |
184 ms |
1328 KB |
Output is correct |
19 |
Correct |
144 ms |
1328 KB |
Output is correct |
20 |
Correct |
160 ms |
1328 KB |
Output is correct |