Submission #869638

# Submission time Handle Problem Language Result Execution time Memory
869638 2023-11-05T07:00:08 Z sleepntsheep Skyscraper (JOI16_skyscraper) C++17
0 / 100
1 ms 2652 KB
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <utility>
#include <array>

using namespace std;
#define ALL(x) x.begin(), x.end()
#define ShinLena cin.tie(nullptr)->sync_with_stdio(false);
using ll = long long;

const ll M = 1'000'000'007;
int n, l, a[100], dp[2][101][1001][3], z;

int main()
{
    ShinLena;
    cin >> n >> l;
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a, a+n);
    dp[1][1][0][0] = 1;
    dp[1][1][0][1] = 1;
    dp[1][1][0][2] = 1;
    for (int i = 1, I = 0, D = a[1] - a[0]; i < n; ++i, I ^= 1, D = a[i] - a[i-1])
    {
        memset(dp[I], 0, sizeof *dp);
        for (int j = 1; j <= 1 + i; ++j)
        {
            for (int k = 0; k <= l; ++k)
            {
                /* dp[I][j][k][0] */ {
                    if ((2*j+2) * D <= k) /* merge */
                        (dp[I][j][k][0] += (dp[!I][j+1][k - ((2*j+2) * D)][0] * j % M)) %= M;

                    if ((2*j-2) * D <= k) /* insert */
                        (dp[I][j][k][0] += (dp[!I][j-1][k - ((2*j-2) * D)][0] * j % M)) %= M;

                    if ((2*j+0) * D <= k) /* append */
                        (dp[I][j][k][0] += (dp[!I][j+0][k - ((2*j+0) * D)][0] * (2*j+0) % M)) %= M;
                }

                /* dp[I][j][k][1] */ {
                    if ((2*j+1) * D <= k) /* merge */
                        (dp[I][j][k][1] += (dp[!I][j+1][k - ((2*j+1) * D)][1] * j % M)) %= M;

                    if (j>1 && (2*j-3) * D <= k) /* non fixing insert */
                        (dp[I][j][k][1] += (dp[!I][j-1][k - ((2*j-3) * D)][1] * (j-1) % M)) %= M;

                    if ((2*j-1) * D <= k) /* non fixing append */
                        (dp[I][j][k][1] += (dp[!I][j+0][k - ((2*j-1) * D)][1] * (2*j-1) % M)) %= M;

                    if ((2*j-2) * D <= k) /* fixing insert */
                        (dp[I][j][k][1] += (dp[!I][j-1][k - ((2*j-2) * D)][0] * 2 % M)) %= M;

                    if ((2*j+0) * D <= k) /* fixing append */
                        (dp[I][j][k][1] += (dp[!I][j+0][k - ((2*j+0) * D)][0] * 2 % M)) %= M;
                }

                /* dp[I][j][k][2] */ {
                    if ((2*j+0) * D <= k) /* merge */
                        (dp[I][j][k][2] += (dp[!I][j+1][k - ((2*j) * D)][2] * j % M)) %= M;

                    if (j>1 && (2*j-4) * D <= k) /* non fixing insert */
                        (dp[I][j][k][2] += (dp[!I][j-1][k - ((2*j-4) * D)][2] * (j-2) % M)) %= M;

                    if ((2*j-2) * D <= k) /* non fixing append */
                        (dp[I][j][k][2] += (dp[!I][j+0][k - ((2*j-2) * D)][2] * (2*j-2) % M)) %= M;

                    if (j>1 && (2*j-3) * D <= k) /* fixing insert */
                        (dp[I][j][k][2] += (dp[!I][j-1][k - ((2*j-3) * D)][1] )) %= M;

                    if ((2*j-1) * D <= k) /* fixing append */
                        (dp[I][j][k][2] += (dp[!I][j+0][k - ((2*j-1) * D)][1] )) %= M;
                }
            }
        }
    }

    for (int k = 0; k <= l; ++k) (z += dp[n&1][1][k][2] % M) %= M;
    cout << z;

    return 0;
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Incorrect 1 ms 2652 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Incorrect 1 ms 2652 KB Output isn't correct
3 Halted 0 ms 0 KB -