Submission #1174719

#TimeUsernameProblemLanguageResultExecution timeMemory
1174719chikien2009Skyscraper (JOI16_skyscraper)C++20
0 / 100
1 ms324 KiB
#include <bits/stdc++.h>

using namespace std;

void setup()
{
#ifndef ONLINE_JUDGE
    freopen("test.inp", "r", stdin);
    freopen("test.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int n, a[101], b, l;
long long f[101][101][1001][3], mod = 1e9 + 7;

int main()
{
    setup();

    cin >> n >> l;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    a[0] = a[1];
    f[0][0][0][0] = 1;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j <= i; ++j)
        {
            for (int k = 0; k <= l; ++k)
            {
                for (int g = 0; g <= 2; ++g)
                {
                    b = (a[i + 1] - a[i]) * (2 * j - g);
                    if (b + k > l || f[i][j][k][g] == 0)
                    {
                        continue;
                    }
                    (f[i + 1][j + 1][k + b][g] += f[i][j][k][g] * (j + 1 - g)) %= mod;
                    if (g < 2)
                    {
                        (f[i + 1][j + 1][k + b][g + 1] += f[i][j][k][g] * (2 - g)) %= mod;
                    }
                    (f[i + 1][j][k + b][g] += f[i][j][k][g] * (2 * j - g)) %= mod;
                    if (g < 2)
                    {
                        (f[i + 1][j][k + b][g + 1] += f[i][j][k][g] * (2 - g)) %= mod;
                    }
                    if (1 < j)
                    {
                        (f[i + 1][j - 1][k + b][g] += f[i][j][k][g] * (j - 1)) %= mod;
                    }
                }
            }
        }
    }
    b = 0;
    for (int i = 1; i <= l; ++i)
    {
        (b += f[n][1][i][2]) % mod;
    }
    cout << b;
    return 0;
}

Compilation message (stderr)

skyscraper.cpp: In function 'void setup()':
skyscraper.cpp:8:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     freopen("test.inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
skyscraper.cpp:9:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     freopen("test.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...