답안 #914336

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914336 2024-01-21T16:55:26 Z borisAngelov Tents (JOI18_tents) C++17
0 / 100
2000 ms 452 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 3005;
const int mod = 1e9 + 7;

int n, m;

long long f(int rows, int cols)
{
    if (rows < 0 || cols < 0)
    {
        return 0;
    }

    if (rows == 0 || cols == 0)
    {
        return 1;
    }

    long long ans = 0;

    ans += f(rows - 1, cols);
    ans %= mod;

    ans += (4LL * cols) * f(rows - 1, cols - 1);
    ans %= mod;

    ans += ((1LL * cols) * (1LL * cols - 1LL) / 2LL) * f(rows - 1, cols - 2);
    ans %= mod;

    ans += (1LL * cols) * (1LL * (rows - 1)) * f(rows - 2, cols - 1);
    ans %= mod;

    return ans;
}

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main()
{
    fastIO();

    cin >> n >> m;

    cout << f(n, m) - 1 << endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 452 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Execution timed out 2084 ms 348 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 452 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Execution timed out 2084 ms 348 KB Time limit exceeded
6 Halted 0 ms 0 KB -