Submission #207998

# Submission time Handle Problem Language Result Execution time Memory
207998 2020-03-09T17:15:16 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);
     ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -