답안 #207997

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
207997 2020-03-09T17:14:40 Z DodgeBallMan Tents (JOI18_tents) C++14
0 / 100
5 ms 1016 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 3010;
const long long mod = 1e9 + 7;
long long dp[N][N];
int h, w;
int main()
{
    scanf("%d %d",&h,&w);
    for( int i = 0 ; i <= w ; i++ ) dp[0][i] = dp[i][0] = 1;
    for( int i = 1 ; i <= h ; i++ ) {
        for( int j = 1 ; j <= w ; j++ ) {
            dp[i][j] = dp[i-1][j];
            dp[i][j] = ( dp[i][j] + dp[i-1][j-1] * 4 * j ) % mod;
            if( i > 1 ) dp[i][j] = ( dp[i][j] + dp[i-2][j-1] * ( long long )( i-1 ) * ( long long )j ) % mod;
            if( j > 1 ) dp[i][j] = ( dp[i][j] + dp[i-1][j-2] * ( ( long long )j * ( long long )(j-1) / 2LL ) ) % mod;
        }
    }
    //printf("%lld ",dp[1][1]);
    printf("%lld",( dp[h][w] - 1 + mod ) % mod );
    return 0;
}

Compilation message

tents.cpp: In function 'int main()':
tents.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&h,&w);
     ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 1016 KB Output is correct
3 Incorrect 5 ms 504 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 1016 KB Output is correct
3 Incorrect 5 ms 504 KB Output isn't correct
4 Halted 0 ms 0 KB -