Submission #869642

# Submission time Handle Problem Language Result Execution time Memory
869642 2023-11-05T07:16:00 Z sleepntsheep Skyscraper (JOI16_skyscraper) C++17
0 / 100
1 ms 2648 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 I, n, l, a[101], dp[2][101][1001][3], z, D;

inline int O(int j, int k, int l)
{
    k -= (2*j-l) * D;
    if (j < 0 || k < 0) return 0;
    return dp[!I][j][k][l];
}

int main()
{
    ShinLena;
    cin >> n >> l;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort(a, a+n);
    dp[1][1][0][0] = 1;
    dp[1][1][0][1] = 2;
    D = a[2] - a[1];
    for (int i = 2; 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] */ {
                    int &d = dp[I][j][k][0];
                    (d += O(j+1, k, 0) * j % M) %= M;

                    (d += O(j-1, k, 0) * j % M) %= M;

                    (d += O(j+0, k, 0) * 2*j % M) %= M;
                }

                /* dp[I][j][k][1] */ {
                    int &d = dp[I][j][k][1];
                    (d += O(j+1, k, 1) * j % M) %= M;

                    (d += O(j-1, k, 1) * (j-1) % M) %= M;

                    (d += O(j+0, k, 1) * (2*j-1) % M) %= M;

                    (d += O(j-1, k, 0) * 2 % M) %= M;

                    (d += O(j+0, k, 0) * 2 % M) %= M;
                }

                /* dp[I][j][k][2] */ {

                    int &d = dp[I][j][k][2];
                    (d += O(j+1, k, 2) * j % M) %= M;

                    (d += O(j-1, k, 2) * (j-2) % M) %= M;

                    (d += O(j+0, k, 2) * (2*j-2) % M) %= M;

                    (d += O(j-1, k, 1) % M) %= M;

                    (d += O(j+0, k, 1) % M) %= M;
                }
            }
        }
    }


    cout << z;

    return 0;
}


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