답안 #236943

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
236943 2020-06-04T05:04:09 Z aggu_01000101 Tents (JOI18_tents) C++14
100 / 100
311 ms 70776 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;
signed main(){
    int h, w;
    cin>>h>>w;
    int dp[h+1][w+1];
    dp[1][1] = 5;
    for(int i = 0;i<=h;i++) dp[i][0] = 1;
    for(int i = 0;i<=w;i++) dp[0][i] = 1;
    for(int i = 2;i<=h;i++){
        dp[i][1] = dp[i-1][1] + (i-1) + 4;
    }
    for(int j = 2;j<=w;j++){
        for(int i = 1;i<=h;i++){
            dp[i][j] = dp[i][j-1];
            dp[i][j]%=MOD;
            dp[i][j] += (((i*(j-1))%MOD)*dp[i-1][j-2])%MOD;
            dp[i][j]%=MOD;
            dp[i][j] += (4*i*dp[i-1][j-1])%MOD;
            dp[i][j]%=MOD;
            if(i>1) dp[i][j] += ((((i*(i-1))/2)%MOD) * (dp[i-2][j-1]))%MOD;
            dp[i][j]%=MOD;
        }
    }
    int ans = (dp[h][w] - 1 + MOD)%MOD;
    cout<<ans<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 6 ms 640 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 6 ms 1024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 6 ms 640 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 6 ms 1024 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 209 ms 44272 KB Output is correct
16 Correct 12 ms 3200 KB Output is correct
17 Correct 41 ms 10112 KB Output is correct
18 Correct 43 ms 12416 KB Output is correct
19 Correct 246 ms 51448 KB Output is correct
20 Correct 201 ms 41080 KB Output is correct
21 Correct 130 ms 27128 KB Output is correct
22 Correct 108 ms 26744 KB Output is correct
23 Correct 46 ms 14976 KB Output is correct
24 Correct 311 ms 70776 KB Output is correct
25 Correct 224 ms 52728 KB Output is correct
26 Correct 292 ms 60408 KB Output is correct
27 Correct 299 ms 68088 KB Output is correct