# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
902530 | 2024-01-10T14:56:58 Z | duckindog | Magneti (COCI21_magneti) | C++14 | 82 ms | 604 KB |
// from duckindog wth depression #include<bits/stdc++.h> using namespace std; const int N = 50 + 10, L = 1e4 + 110, M = 1e9 + 7; int n, l; int r[N]; void sub1() { vector<long long> d(l + 1), f(l + 1); const int x = r[1]; for (int i = 1; i <= l; ++i) d[i] = (d[i - 1] + n) % M; for (int i = 2; i <= n; ++i) { fill(f.begin(), f.end(), 0); for (int j = x; j <= l; ++j) f[j] = (d[j - x] * (n - i + 1)) % M; for (int j = 1; j <= l; ++j) d[j] = (d[j - 1] + f[j]) % M; } cout << d[l]; } const int S2 = 2e4 + 10; int fac[S2], ifac[S2]; int powder(int a, int b) { long long ret = 1; while (b) { if (b & 1) ret = ret * a % M; a = 1ll * a * a % M; b /= 2; } return ret; } int C(int n, int k) { if (k < 0) return 0; return 1ll * fac[n] * ifac[k] % M * ifac[n - k] % M; } void init() { int x = 2e4; 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 sub2() { init(); vector<int> per; for (int i = 1; i <= n; ++i) per.push_back(i); int answer = 0; do { int people = l - n; for (int i = 1; i < n; ++i) people -= max(r[per[i]] - 1, r[per[i - 1]] - 1); answer = (1ll * answer + C(n + people, people)) % M; } while (next_permutation(per.begin(), per.end())); cout << answer; } 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); } cin >> n >> l; for(int i = 1; i <= n; ++i) cin >> r[i]; sort(r + 1, r + n + 1); int sub = r[1] == r[n] ? 1 : n <= 10 ? 2 : (n <= 30 && l <= 300) ? 3 : 4; if (sub == 1) { sub1(); return 0; } if (sub == 2) { sub2(); return 0; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 604 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 456 KB | Output is correct |
4 | Correct | 1 ms | 604 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 2 ms | 588 KB | Output is correct |
7 | Correct | 2 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 82 ms | 604 KB | Output is correct |
2 | Correct | 1 ms | 456 KB | Output is correct |
3 | Correct | 80 ms | 604 KB | Output is correct |
4 | Correct | 1 ms | 604 KB | Output is correct |
5 | Correct | 50 ms | 604 KB | Output is correct |
6 | Correct | 1 ms | 604 KB | Output is correct |
7 | Correct | 49 ms | 600 KB | Output is correct |
8 | Correct | 48 ms | 600 KB | Output is correct |
9 | Correct | 1 ms | 604 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 604 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 456 KB | Output is correct |
4 | Correct | 1 ms | 604 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 2 ms | 588 KB | Output is correct |
7 | Correct | 2 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 82 ms | 604 KB | Output is correct |
12 | Correct | 1 ms | 456 KB | Output is correct |
13 | Correct | 80 ms | 604 KB | Output is correct |
14 | Correct | 1 ms | 604 KB | Output is correct |
15 | Correct | 50 ms | 604 KB | Output is correct |
16 | Correct | 1 ms | 604 KB | Output is correct |
17 | Correct | 49 ms | 600 KB | Output is correct |
18 | Correct | 48 ms | 600 KB | Output is correct |
19 | Correct | 1 ms | 604 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Incorrect | 1 ms | 348 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |