Submission #769331

# Submission time Handle Problem Language Result Execution time Memory
769331 2023-06-29T12:27:43 Z LucaIlie Tents (JOI18_tents) C++17
0 / 100
106 ms 213056 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 301;
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 1 ms 340 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 564 KB Output is correct
4 Correct 1 ms 2516 KB Output is correct
5 Correct 14 ms 38008 KB Output is correct
6 Correct 22 ms 48328 KB Output is correct
7 Correct 17 ms 47268 KB Output is correct
8 Correct 17 ms 35888 KB Output is correct
9 Correct 1 ms 2096 KB Output is correct
10 Correct 49 ms 96244 KB Output is correct
11 Correct 3 ms 7380 KB Output is correct
12 Incorrect 106 ms 213056 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 564 KB Output is correct
4 Correct 1 ms 2516 KB Output is correct
5 Correct 14 ms 38008 KB Output is correct
6 Correct 22 ms 48328 KB Output is correct
7 Correct 17 ms 47268 KB Output is correct
8 Correct 17 ms 35888 KB Output is correct
9 Correct 1 ms 2096 KB Output is correct
10 Correct 49 ms 96244 KB Output is correct
11 Correct 3 ms 7380 KB Output is correct
12 Incorrect 106 ms 213056 KB Output isn't correct
13 Halted 0 ms 0 KB -