답안 #207999

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
207999 2020-03-09T17:16:12 Z DodgeBallMan Tents (JOI18_tents) C++14
100 / 100
109 ms 71032 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] = 1;
    for( int i = 0 ; i <= h ; 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 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 5 ms 1144 KB Output is correct
5 Correct 5 ms 632 KB Output is correct
6 Correct 5 ms 1404 KB Output is correct
7 Correct 5 ms 764 KB Output is correct
8 Correct 5 ms 1404 KB Output is correct
9 Correct 5 ms 760 KB Output is correct
10 Correct 6 ms 1784 KB Output is correct
11 Correct 5 ms 380 KB Output is correct
12 Correct 6 ms 2296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 5 ms 1144 KB Output is correct
5 Correct 5 ms 632 KB Output is correct
6 Correct 5 ms 1404 KB Output is correct
7 Correct 5 ms 764 KB Output is correct
8 Correct 5 ms 1404 KB Output is correct
9 Correct 5 ms 760 KB Output is correct
10 Correct 6 ms 1784 KB Output is correct
11 Correct 5 ms 380 KB Output is correct
12 Correct 6 ms 2296 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 9 ms 9720 KB Output is correct
15 Correct 72 ms 55160 KB Output is correct
16 Correct 9 ms 4088 KB Output is correct
17 Correct 20 ms 12920 KB Output is correct
18 Correct 24 ms 17144 KB Output is correct
19 Correct 89 ms 62968 KB Output is correct
20 Correct 66 ms 50936 KB Output is correct
21 Correct 61 ms 33784 KB Output is correct
22 Correct 48 ms 35448 KB Output is correct
23 Correct 32 ms 27128 KB Output is correct
24 Correct 109 ms 71032 KB Output is correct
25 Correct 89 ms 61304 KB Output is correct
26 Correct 101 ms 66808 KB Output is correct
27 Correct 106 ms 69112 KB Output is correct