Submission #448683

#TimeUsernameProblemLanguageResultExecution timeMemory
448683ymmSkyscraper (JOI16_skyscraper)C++17
100 / 100
578 ms5280 KiB
/// /// I have a dream and a piano /// #define _USE_MATH_DEFINES #define FAST ios::sync_with_stdio(false),cin.tie(0); #include <bits/stdc++.h> #define Loop(x, l, r) for(int x = (l); x < (r); ++x) #define LoopR(x, l, r) for(int x = (r)-1; x >= (l); --x) #define all(x) x.begin(), x.end() #define Kill(x) exit((cout << (x) << '\n', 0)) #define YN(flag) ((flag)? "YES": "NO") #define F first #define S second typedef long long ll; typedef unsigned long long ull; typedef std::pair<int,int> pii; typedef std::pair<ll ,ll > pll; using namespace std; const int N = 105; const int L = 1005; const int mod = 1e9 + 7; ll dp1[N][L][3]; ll dp2[N][L][3]; int a[N]; int n, l; int main() { FAST; cin >> n >> l; Loop(i,0,n) cin >> a[i]; sort(a, a+n); dp1[0][0][0] = 1; Loop(i,0,n) { Loop(k,0,N) Loop(l,0,L) Loop(r,0,3) { ll x = i? a[i] - a[i-1]: a[0]; x = (2*k - r)*x + l; if(x < 0 || x >= L) continue; if(k > 0) dp2[k-1][x][r] += (k-1) * dp1[k][l][r]; if(true) dp2[k][x][r] += (2*k-r) * dp1[k][l][r]; if(r+!k < 2) dp2[k+!k][x][r+1+!k] += (2-r-!k) * dp1[k][l][r]; if(r < 2 && k < N-1) dp2[k+1][x][r+1] += (2-r) * dp1[k][l][r]; if(k < N-1) dp2[k+1][x][r] += (k+1-r) * dp1[k][l][r]; } Loop(k,0,N) Loop(l,0,L) Loop(r,0,3) dp1[k][l][r] = dp2[k][l][r] % mod, dp2[k][l][r] = 0; } ll ans = 0; Loop(i,0,l+1) ans += dp1[1][i][2]; cout << ans%mod << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...