Submission #638003

#TimeUsernameProblemLanguageResultExecution timeMemory
638003Do_you_copySkyscraper (JOI16_skyscraper)C++17
15 / 100
1 ms724 KiB
#include <bits/stdc++.h> #define int long long #define fi first #define se second #define pb push_back #define faster ios_base::sync_with_stdio(0); cin.tie(0); using namespace std; using ll = long long; using ull = unsigned ll; using ld = long double; using pii = pair <int, int>; using pil = pair <int, ll>; using pli = pair <ll, int>; using pll = pair <ll, ll>; mt19937 Rand(chrono::steady_clock::now().time_since_epoch().count()); ll min(const ll &a, const ll &b){ return (a < b) ? a : b; } ll max(const ll &a, const ll &b){ return (a > b) ? a : b; } const ll Mod = 1000000007; //const ll Mod2 = 999999999989; //only use when required const int maxN = 1e2 + 10; const int maxL = 1e3 + 10; int n, L; int a[maxN]; ll dp[maxN][maxN][maxL][3]; void Init(){ cin >> n >> L; a[n] = 1e7; for (int i = 0; i < n; ++i) cin >> a[i]; sort(a, a + n); dp[0][0][0][0] = 1; for (int i = 1; i <= n; ++i){ for (int j = 1; j <= i; ++j){ for (int k = 0; k <= L; ++k){ for (int m = 0; m <= 2; ++m){ ll delta = (2 * j - m) * (a[i] - a[i - 1]); if (delta > k|| i + j + 1 - m > n) continue; dp[i][j][k][m] += dp[i - 1][j - 1][k - delta][m]; if (m > 0){ dp[i][j][k][m] += (3 - m) * dp[i - 1][j - 1][k - delta][m - 1]; if (m == 1) dp[i][j][k][m] += 2 * j * dp[i - 1][j][k - delta][m - 1]; else if (m == 2 && i == n) dp[i][j][k][m] += dp[i - 1][j][k - delta][m - 1]; else dp[i][j][k][m] += (j - 1) * dp[i - 1][j][k - delta][m - 1]; } dp[i][j][k][m] += (2 * j - m) * dp[i - 1][j][k - delta][m]; if (m == 2 && i == n) dp[i][j][k][m] += dp[i - 1][j + 1][k - delta][m]; else if (m == 2) dp[i][j][k][m] += j * (j - 1) * dp[i - 1][j + 1][k - delta][m]; else if (m == 1) dp[i][j][k][m] += j * j * dp[i - 1][j + 1][k - delta][m]; else dp[i][j][k][m] += j * (j + 1) * dp[i - 1][j + 1][k - delta][m]; dp[i][j][k][m] %= Mod; } } } } ll ans = 0; for (int i = 0; i <= L; ++i){ ans += dp[n][1][i][2]; ans %= Mod; } cout << ans; } #define debug #define taskname "test" signed main(){ if (fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); #ifdef debug freopen(taskname".out", "w", stdout); #endif } faster; ll tt = 1; //cin >> tt; while (tt--){ Init(); } if (fopen("timeout.txt", "r")){ ofstream timeout("timeout.txt"); timeout << 1000 * double(clock()) / CLOCKS_PER_SEC; #ifndef debug cerr << "\nTime elapsed: " << 1000 * double(clock()) / CLOCKS_PER_SEC << "ms\n"; #endif } }

Compilation message (stderr)

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:75:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
skyscraper.cpp:77:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   77 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...