# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3846 | wookayin | Hexagon travel (kriii1_H) | C++98 | 376 ms | 1212 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.
#include <stdio.h>
#include <memory.h>
const int mod = 1000000007;
int p[2][4023];
int d[2][2005][6];
int cm[6];
int main()
{
int l,r,m;
scanf("%d%d%d",&l,&r,&m);
for(int i = 0; i <= l+r; i++){
int ci = i % 2;
int li = 1 - ci;
p[ci][0] = p[ci][i] = 1;
for(int j = 1; j < i; j++) {
p[ci][j] = (p[li][j] + p[li][j-1])%mod;
}
}
cm[0] = 2;
cm[1] = 5;
cm[2] = 4;
cm[3] = 1;
cm[4] = 0;
cm[5] = 3;
d[0][0][4] = 1;
for(int i = 0; i <= l+r; i++) {
int ci = i%2;
int ni = 1-ci;
memset(d[ni],0,sizeof(d[0]));
for(int j = 0; j <= m; j++) {
for(int k = 0; k < 6;k ++){
d[ni][j][k^1] = (d[ni][j][k^1] + d[ci][j][k])%mod;
d[ci][j+1][cm[k]] = (d[ci][j+1][cm[k]] + d[ci][j][k])%mod;
}
}
}
for(int j = 0;j < 3;j++)
{
long long ans = 0;
for(int i = 0; i <2; i++){
ans += d[(l+r)%2][m][i+j*2];
}
ans %= mod;
ans *= p[(l+r)%2][l];
ans %= mod;
printf("%d\n", (int)ans);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |