답안 #1026555

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1026555 2024-07-18T07:56:12 Z hqminhuwu Skyscraper (JOI16_skyscraper) C++14
15 / 100
3 ms 5976 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
typedef pair <int,int> pii;
typedef pair <int,pii> piii;

#define forr(_a,_b,_c) for(int _a = (_b); _a <= (_c); ++_a)
#define ford(_a,_b,_c) for(int _a = (_b) + 1; _a --> (_c);)
#define forf(_a,_b,_c) for(int _a = (_b); _a < (_c); ++_a)
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define all(x) begin(x),end(x)
#define mask(i) (1LL << (i))
#define bit(x, i) (((x) >> (i)) & 1)
#define bp __builtin_popcountll
#define file "test"

template<class X, class Y>
    bool minz(X &x, const Y &y) {
        if (x > y) {
            x = y;
            return true;
        } return false;
    }
template<class X, class Y>
    bool maxz(X &x, const Y &y) {
        if (x < y) {
            x = y;
            return true;
        } return false;
    }

const int N = 5e5 + 5;
const ll oo = (ll) 1e16;
const ll mod = 1e9 + 7; // 998244353;

ll n, l, a[N], dp[105][105][1005][4];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifdef hqm
        freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);
    #endif

    cin >> n >> l;

    forr (i, 1, n){
        cin >> a[i];
    }

    sort(a + 1, a + 1 + n);

    dp[1][0][0][0] = 1;
    ll res = 0;

    forr (i, 1, n){
        forr (j, 0, n){
            forr (k, 0, l){
                forr (t, 0, 2){
                    //if (j == 0 && t != 0) continue;
                    if (dp[i][j][k][t]){
                       // cout << i << " " << j << " " << k << " " << t << " " << dp[i][j][k][t] << "\n";
                    }
                    int nk;
                    nk = min(l + 1, k + ((j + 1) * 2 - t) * (a[i + 1] - a[i]));
                    (dp[i + 1][j + 1][nk][t] += dp[i][j][k][t] * (j + 1 - t)) %= mod;
                    nk = min(l + 1, k + ((j + 1) * 2 - (t + 1)) * (a[i + 1] - a[i]));
                    (dp[i + 1][j + 1][nk][t + 1] += dp[i][j][k][t] * (2 - t)) %= mod;
                    if (j >= 1){
                        nk = min(l + 1, k + (j * 2 - t) * (a[i + 1] - a[i]));
                        (dp[i + 1][j][nk][t] += dp[i][j][k][t] * (2 * j - t)) %= mod;
                        nk = min(l + 1, k + (j * 2 - (t + 1)) * (a[i + 1] - a[i]));
                        (dp[i + 1][j][nk][t + 1] += dp[i][j][k][t] * (2 - t)) %= mod;
                    }
                    if (j - t >= 2){
                        nk = min (l + 1, k + ((j - 1) * 2 - t) * (a[i + 1] - a[i]));
                        (dp[i + 1][j - 1][nk][t] += dp[i][j][k][t] * (j - t - 1)) %= mod;
                    }
                    if (t && j > t){
                        nk = min(l + 1, k + ((j - 1) * 2 - t) * (a[i + 1] - a[i]));
                        (dp[i + 1][j - 1][nk][t] += dp[i][j][k][t] * t) %= mod;
                    }
                    if (t == 2 && j == 2 && i == n){
                        (res += dp[i][j][k][t]) %= mod;
                    }
                    if (t == 1 && j == 1 && i == n){
                        (res += dp[i][j][k][t]) %= mod;
                    }
                }
            }
        }
    }


    cout << res % mod;

    return 0;
}
/*



*/

# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5468 KB Output is correct
2 Correct 3 ms 5724 KB Output is correct
3 Correct 2 ms 5468 KB Output is correct
4 Correct 3 ms 5724 KB Output is correct
5 Correct 3 ms 5976 KB Output is correct
6 Correct 3 ms 5724 KB Output is correct
7 Correct 2 ms 5528 KB Output is correct
8 Correct 1 ms 5468 KB Output is correct
9 Correct 2 ms 5724 KB Output is correct
10 Correct 2 ms 5976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -