Submission #102527

#TimeUsernameProblemLanguageResultExecution timeMemory
102527MinnakhmetovSkyscraper (JOI16_skyscraper)C++14
20 / 100
35 ms4280 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 = 15, S = 3e4 + 5, MOD = 1e9 + 7; int a[N], dp[N][2][2][N][S]; void f(int &a, int b) { a += b; if (a >= MOD) a -= 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); reverse(a, a + n); dp[1][0][0][0][0] = 1; dp[1][1][1][0][a[0] + a[0]] = 1; dp[1][0][1][0][a[0]] = 1; dp[1][1][0][0][a[0]] = 1; for (int i = 1; i < n; i++) { for (int x = 0; x < 2; x++) { for (int y = 0; y < 2; y++) { for (int j = 0; j < i; j++) { for (int k = 0; k < S; k++) { if (dp[i][x][y][j][k]) { int cur = dp[i][x][y][j][k]; if (j) { f(dp[i + 1][x][y][j][k], cur * j * 2 % MOD); f(dp[i + 1][x][y][j + 1][k + a[i] + a[i]], cur * j % MOD); f(dp[i + 1][x][y][j - 1][k - a[i] - a[i]], cur * j % MOD); } if (x) { f(dp[i + 1][0][y][j][k - a[i]], cur); f(dp[i + 1][1][y][j][k], cur); f(dp[i + 1][0][y][j + 1][k + a[i]], cur); f(dp[i + 1][1][y][j + 1][k + a[i] + a[i]], cur); } if (y) { f(dp[i + 1][x][0][j][k - a[i]], cur); f(dp[i + 1][x][1][j][k], cur); f(dp[i + 1][x][0][j + 1][k + a[i]], cur); f(dp[i + 1][x][1][j + 1][k + a[i] + a[i]], cur); } } } } } } } //for (int x = 0; x < 2; x++) { // for (int y = 0; y < 2; y++) { // for (int j = 0; j < 4; j++) { // for (int k = 0; k < 15; k++) { // cout << x << " " << y << " " << j << " " << k << " : " << dp[4][x][y][j][k] << "\n"; // } // } // } //} int ans = 0; for (int i = 0; i <= l; i++) { f(ans, dp[n][0][0][0][i]); } 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...