Submission #741122

# Submission time Handle Problem Language Result Execution time Memory
741122 2023-05-13T15:00:38 Z Danilo21 Skyscraper (JOI16_skyscraper) C++14
0 / 100
1 ms 1108 KB
#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define en '\n'
#define sp ' '
#define tb '\t'
#define ri(n) int n; cin >> n
#define rl(n) ll n; cin >> n
#define rs(s) string s; cin >> s
#define rc(c) char c; cin >> c
#define rv(v) for (auto &x : v) cin >> x
#define pven(v) for (auto x : v) cout << x << en
#define pv(v) for (auto x : v) cout << x << sp; cout << en
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yes cout << "YES" << en
#define no cout << "NO" << en
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define ssort(a, b) if (a < b) swap(a, b)
#define bitcnt(a) __builtin_popcountll(a)
#define bithigh(a) 63-__builtin_clzll(a)
#define lg bithigh
ll highpow(ll a) { return 1LL << (ll)lg(a); }

using namespace std;

const ll LINF = 4e18;
const int mxN = 1e2+10, INF = 2e9, mod = 1e9+7;
ll n, m, a[mxN], dp[mxN][mxN][10*mxN][3];

ll add(ll x, ll y){ return (x + y) % mod; }
#define sadd(a, b) a = add(a, b)

void Solve(){

    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    sort(a+1, a+n+1); reverse(a+1, a+n+1);
    a[0] = 0;
    a[n+1] = a[n];
    dp[0][0][0][0] = 1;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            for (int s = 1; s <= m; s++){
                int d = a[i+1] - a[i];
                for (int k = 0; k < 3; k++){
                    if (s >= (2*j-k)*d){
                        sadd(dp[i][j][s][k], (j-k)*dp[i-1][j-1][s - (2*j-k)*d][k]);
                        sadd(dp[i][j][s][k], (2*j-k)*dp[i-1][j][s - (2*j-k)*d][k]);
                        sadd(dp[i][j][s][k], j*dp[i-1][j+1][s - (2*j-k)*d][k]);
                        if (k){
                            sadd(dp[i][j][s][k], dp[i-1][j-1][s - (2*j-k)*d][k-1]);
                            sadd(dp[i][j][s][k], dp[i-1][j][s - (2*j-k)*d][k-1]);
                        }
                    }
                }
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i <= m; i++)
        sadd(ans, dp[n][1][i][2]);
    cout << ans << en;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0); cerr.tie(0);
    cout << setprecision(12) << fixed;
    cerr << setprecision(12) << fixed;
    cerr << "Started!" << endl;

    int t = 1;
    //cin >> t;
    while (t--)
        Solve();

    return 0;
}

Compilation message

skyscraper.cpp: In function 'long long int highpow(long long int)':
skyscraper.cpp:26:22: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   26 | #define bithigh(a) 63-__builtin_clzll(a)
      |                      ^
skyscraper.cpp:27:12: note: in expansion of macro 'bithigh'
   27 | #define lg bithigh
      |            ^~~~~~~
skyscraper.cpp:28:38: note: in expansion of macro 'lg'
   28 | ll highpow(ll a) { return 1LL << (ll)lg(a); }
      |                                      ^~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -