# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
902898 | 2024-01-11T04:31:44 Z | duckindog | Magneti (COCI21_magneti) | C++14 | 228 ms | 52892 KB |
//from duckindog wth depression #include<bits/stdc++.h> using namespace std; const int N = 50 + 10, L = 1e4 + 10, M = 1e9 + 7; int n, l; int a[N]; int f[N][N][L]; const int F = 1e5 + 10; int fac[F], ifac[F]; int powder(int a, int b) { int ret = 1; while (b) { if (b & 1) ret = 1ll * ret * a % M; a = 1ll * a * a % M; b /= 2; } return ret; } int C(int n, int k) { return 1ll * fac[n] * ifac[k] % M * ifac[n - k] % M; } void init() { int x = 1e5; fac[1] = 1; for (int i = 2; i <= x; ++i) fac[i] = 1ll * fac[i - 1] * i % M; ifac[x] = powder(fac[x], M - 2); for (int i = x; i >= 1; --i) ifac[i - 1] = 1ll * ifac[i] * i % M; } void add(int &x, int y) { x = ((1ll * x + y) % M + M) % M; } int32_t main() { cin.tie(0)->sync_with_stdio(0); if (fopen("duck.inp", "r")) { freopen("duck.inp", "r", stdin); freopen("duck.out", "w", stdout); } init(); cin >> n >> l; for (int i = 1; i <= n; ++i) cin >> a[i]; sort(a + 1, a + n + 1); f[0][0][0] = 1; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= i; ++j) { for (int t = 1; t <= l; ++t) { auto &ret = f[i][j][t]; int r = a[i]; //create add(ret, f[i - 1][j - 1][t - 1]); //add if (r <= t) add(ret, 1ll * f[i - 1][j][t - r] * 2 * j % M); //connect if (2 * r - 1 <= t) add(ret, 1ll * f[i - 1][j + 1][t - 2 * r + 1] * C(2, j) % M); } } } int answer = 0; for (int i = 1; i <= l; ++i) add(answer, f[n][1][i] * C(n + l - i, n) % M); cout << answer << '\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 228 ms | 52892 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 11 ms | 4712 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 5224 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 228 ms | 52892 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |