Submission #1258850

#TimeUsernameProblemLanguageResultExecution timeMemory
1258850Sam_arvandiSkyscraper (JOI16_skyscraper)C++20
0 / 100
259 ms224872 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pii; #define FOR(i, j, n) for(ll i = j; i<= n; i++) #define ROF(i, n, j) for(ll i = n; i>= j; i--) #define pb push_back #define F first #define S second #define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define G(i, j) get<j-1>(i) #define prll(x) cout << #x << ": " << x << endl; const ll mn = 14 + 5, mn2 = (1<<14) + 5, ml = 100 + 5, mod = 1e9 + 7; ll dp[mn2][mn][ml], a[mn], two[mn]; inline ll ghadr(ll x, ll y) { return max(x, y)-min(x, y); } signed main() { IOS; ll n, L; cin >> n >> L; two[0] = 1; FOR(i, 1, n) { two[i] = two[i-1]*2; } FOR(i, 1, n) cin >> a[i]; FOR(mask, 1, (1<<n)-1) { ll t = 0; vector<ll> tmp; FOR(j, 0, n-1) { if ((mask&two[j])) { t++; tmp.pb(j+1); } } if (t == 1) { ll i = tmp[0]; FOR(j, 0, L) { dp[mask][i][j] = 1; } continue; } for(auto i: tmp) { FOR(x, 0, L) { for(auto j: tmp) { if (j == i) continue; dp[mask][i][x] += dp[mask-two[i-1]][j][x-ghadr(a[i], a[j])]; } } } } ll ans = 0; FOR(i, 1, n) { ans += dp[(1<<n)-1][i][L]; } cout << ans%mod; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...