Submission #769334

# Submission time Handle Problem Language Result Execution time Memory
769334 2023-06-29T12:28:01 Z LucaIlie Tents (JOI18_tents) C++17
48 / 100
143 ms 354472 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 500;
const int MOD = 1e9 + 7;

long long dp[MAX_N][MAX_N][MAX_N];

int main() {
    int n, m;

    cin >> n >> m;
    dp[0][m][0] = 1;
    for ( int i = 1; i <= n; i++ ) {
        for ( int c = 0; c <= m; c++ ) {
            for ( int l = 0; l <= i; l++ ) {
                dp[i][c][l] = (l > 0 ? dp[i - 1][c][l - 1] : 0)
                              + dp[i - 1][c + 1][l] * (c + 1) * 4
                              + dp[i - 1][c + 2][l] * (c + 2) * (c + 1) / 2
                              + dp[i - 1][c + 1][l + 1] * (c + 1) * (l + 1);
                dp[i][c][l] %= MOD;
            }
        }
    }

    int sol = 0;

    for ( int c = 0; c < m; c++ ) {
        for ( int l = 0; l <= n; l++ )
            sol = (sol + dp[n][c][l]) % MOD;
    }

    cout << sol;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 1748 KB Output is correct
3 Correct 1 ms 852 KB Output is correct
4 Correct 2 ms 3668 KB Output is correct
5 Correct 27 ms 62756 KB Output is correct
6 Correct 32 ms 79780 KB Output is correct
7 Correct 28 ms 78164 KB Output is correct
8 Correct 25 ms 59088 KB Output is correct
9 Correct 2 ms 3156 KB Output is correct
10 Correct 66 ms 159212 KB Output is correct
11 Correct 4 ms 12116 KB Output is correct
12 Correct 143 ms 354472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 1748 KB Output is correct
3 Correct 1 ms 852 KB Output is correct
4 Correct 2 ms 3668 KB Output is correct
5 Correct 27 ms 62756 KB Output is correct
6 Correct 32 ms 79780 KB Output is correct
7 Correct 28 ms 78164 KB Output is correct
8 Correct 25 ms 59088 KB Output is correct
9 Correct 2 ms 3156 KB Output is correct
10 Correct 66 ms 159212 KB Output is correct
11 Correct 4 ms 12116 KB Output is correct
12 Correct 143 ms 354472 KB Output is correct
13 Incorrect 3 ms 7508 KB Output isn't correct
14 Halted 0 ms 0 KB -