답안 #3846

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3846 2013-08-31T08:48:08 Z wookayin Hexagon travel (kriii1_H) C++
1 / 1
376 ms 1212 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1212 KB Output is correct
2 Correct 0 ms 1212 KB Output is correct
3 Correct 0 ms 1212 KB Output is correct
4 Correct 0 ms 1212 KB Output is correct
5 Correct 0 ms 1212 KB Output is correct
6 Correct 8 ms 1212 KB Output is correct
7 Correct 0 ms 1212 KB Output is correct
8 Correct 0 ms 1212 KB Output is correct
9 Correct 16 ms 1212 KB Output is correct
10 Correct 376 ms 1212 KB Output is correct
11 Correct 220 ms 1212 KB Output is correct
12 Correct 120 ms 1212 KB Output is correct
13 Correct 40 ms 1212 KB Output is correct
14 Correct 116 ms 1212 KB Output is correct
15 Correct 112 ms 1212 KB Output is correct
16 Correct 36 ms 1212 KB Output is correct
17 Correct 104 ms 1212 KB Output is correct
18 Correct 124 ms 1212 KB Output is correct
19 Correct 48 ms 1212 KB Output is correct
20 Correct 68 ms 1212 KB Output is correct