Submission #102608

#TimeUsernameProblemLanguageResultExecution timeMemory
102608MinnakhmetovSkyscraper (JOI16_skyscraper)C++14
100 / 100
57 ms15992 KiB
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #include <cstring> #include <unordered_map> #include <unordered_set> using namespace std; #define ll long long #define all(aaa) aaa.begin(), aaa.end() #pragma warning(disable : 4996) const int N = 101, L = 1001, MOD = 1e9 + 7; int dp[N][N][L][3], a[N]; void f(int &a, ll b) { a = (a + b) % MOD; } signed main() { #ifdef HOME freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ios_base::sync_with_stdio(0); cin.tie(0); int n, l; cin >> n >> l; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); dp[1][0][0][0] = 1; dp[1][0][0][2] = 1; dp[1][0][0][1] = 2; for (int i = 1; i < n; i++) { int d = a[i] - a[i - 1]; for (int j = 0; j < i; j++) { for (int k = 0; k <= l; k++) { for (int x = 0; x < 3; x++) { int nk = k + (x + j * 2) * d; if (dp[i][j][k][x] && nk <= l) { ll cur = dp[i][j][k][x]; if (j) { f(dp[i + 1][j - 1][nk][x], cur * j); f(dp[i + 1][j + 1][nk][x], cur * j); f(dp[i + 1][j][nk][x], (cur + cur) * j); } if (x) { f(dp[i + 1][j][nk][x - 1], cur * x); f(dp[i + 1][j][nk][x], cur * x); f(dp[i + 1][j + 1][nk][x - 1], cur * x); f(dp[i + 1][j + 1][nk][x], cur * x); } } } } } } ll ans = 0; for (int i = 0; i <= l; i++) ans += dp[n][0][i][0]; ans %= MOD; cout << ans; return 0; }

Compilation message (stderr)

skyscraper.cpp:41:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable : 4996)
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...