# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
638004 | 2022-09-04T07:46:01 Z | Do_you_copy | Skyscraper (JOI16_skyscraper) | C++17 | 1 ms | 724 KB |
#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; if (n == 1){ cout << 0; return; } 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 596 KB | Output is correct |
2 | Correct | 1 ms | 596 KB | Output is correct |
3 | Correct | 1 ms | 596 KB | Output is correct |
4 | Correct | 1 ms | 596 KB | Output is correct |
5 | Correct | 1 ms | 596 KB | Output is correct |
6 | Correct | 1 ms | 596 KB | Output is correct |
7 | Correct | 0 ms | 596 KB | Output is correct |
8 | Correct | 1 ms | 596 KB | Output is correct |
9 | Correct | 1 ms | 724 KB | Output is correct |
10 | Correct | 1 ms | 596 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |