답안 #582744

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
582744 2022-06-24T11:12:33 Z elkernos Tents (JOI18_tents) C++17
100 / 100
124 ms 70916 KB
#include <bits/stdc++.h>

using namespace std;

const int mod = 1000 * 1000 * 1000 + 7;

int main()
{
    cin.tie(nullptr)->sync_with_stdio(0);
    int h, w;
    cin >> h >> w;
    vector<vector<long long>> dp(h + 1, vector<long long>(w + 1));
    auto C2 = [](int x) {
        return x * (x - 1) / 2;
    };
    for(int i = 0; i <= h; i++) {
        for(int j = 0; j <= w; j++) {
            if(i == 0 || j == 0) {
                dp[i][j] = 1;
                continue;
            }
            dp[i][j] += dp[i][j - 1];
            dp[i][j] += 4ll * i * dp[i - 1][j - 1];
            if(i >= 2) {
                dp[i][j] += C2(i) * dp[i - 2][j - 1];
            }
            if(j >= 2) {
                dp[i][j] += i * (j - 1) * dp[i - 1][j - 2];
            }
            dp[i][j] %= mod;
        }
    }
    cout << (dp[h][w] - 1 + mod) % mod << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 316 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 456 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 316 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 456 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 980 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 444 KB Output is correct
15 Correct 70 ms 44192 KB Output is correct
16 Correct 5 ms 3028 KB Output is correct
17 Correct 16 ms 10068 KB Output is correct
18 Correct 22 ms 12508 KB Output is correct
19 Correct 95 ms 51468 KB Output is correct
20 Correct 70 ms 41188 KB Output is correct
21 Correct 52 ms 27164 KB Output is correct
22 Correct 45 ms 26836 KB Output is correct
23 Correct 26 ms 15060 KB Output is correct
24 Correct 119 ms 70916 KB Output is correct
25 Correct 85 ms 52672 KB Output is correct
26 Correct 102 ms 60384 KB Output is correct
27 Correct 124 ms 68168 KB Output is correct