답안 #1109770

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1109770 2024-11-07T14:17:30 Z ttamx Tents (JOI18_tents) C++17
100 / 100
95 ms 70984 KB
#include<bits/stdc++.h>

using namespace std;

using ll = long long;

const int N=3005;
const int MOD=1e9+7;

int h,w;
ll dp[N][N];

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> h >> w;
    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=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            dp[i][j]+=dp[i-1][j];
            dp[i][j]%=MOD;
            dp[i][j]+=dp[i-1][j-1]*j*4;
            dp[i][j]%=MOD;
            if(i>=2){
                dp[i][j]+=dp[i-2][j-1]*(i-1)*j%MOD;
                dp[i][j]%=MOD;
            }
            if(j>=2){
                dp[i][j]+=dp[i-1][j-2]*(1LL*j*(j-1)/2)%MOD;
                dp[i][j]%=MOD;
            }
        }
    }
    cout << (dp[h][w]-1+MOD)%MOD;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 6480 KB Output is correct
5 Correct 1 ms 2516 KB Output is correct
6 Correct 1 ms 6480 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 6480 KB Output is correct
9 Correct 1 ms 4432 KB Output is correct
10 Correct 2 ms 8712 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 3 ms 8696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 6480 KB Output is correct
5 Correct 1 ms 2516 KB Output is correct
6 Correct 1 ms 6480 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 6480 KB Output is correct
9 Correct 1 ms 4432 KB Output is correct
10 Correct 2 ms 8712 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 3 ms 8696 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 6 ms 55888 KB Output is correct
15 Correct 67 ms 66128 KB Output is correct
16 Correct 6 ms 6736 KB Output is correct
17 Correct 18 ms 16976 KB Output is correct
18 Correct 20 ms 29264 KB Output is correct
19 Correct 74 ms 70228 KB Output is correct
20 Correct 59 ms 57936 KB Output is correct
21 Correct 39 ms 39504 KB Output is correct
22 Correct 41 ms 51792 KB Output is correct
23 Correct 26 ms 70480 KB Output is correct
24 Correct 95 ms 70984 KB Output is correct
25 Correct 73 ms 62032 KB Output is correct
26 Correct 85 ms 68176 KB Output is correct
27 Correct 90 ms 70224 KB Output is correct