Submission #1047220

#TimeUsernameProblemLanguageResultExecution timeMemory
1047220nima_aryanSkyscraper (JOI16_skyscraper)C++14
Compilation error
0 ms0 KiB
/** * author: NimaAryan * created: 2024-06-26 20:39:48 **/ #include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "algo/debug.h" #endif using i64 = long long; constexpr i64 mod = 1E9 + 7; void add(i64& x, i64 y) { if ((x += y) >= mod) { x -= mod; } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, L; cin >> N >> L; vector<int> A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } if (N == 1) { cout << 1 << "\n"; return 0; } sort(A.begin(), A.end()); A.push_back(10000); vector f(3, vector(N + 1, vector<i64>(L + 1))); f[0][0][0] = 1; for (int i = 0; i < N; ++i) { vector g(3, vector(N + 1, vector<i64>(L + 1))); for (int p = 0; p < 3; ++p) { for (int c = 0; c <= N; ++c) { for (int s = 0; s <= L; ++s) { int d = A[i + 1] - A[i]; int new_s = s + (2 * c - p) * d; { if (c + 1 <= N && 0 <= new_s + 2 * d && new_s + 2 * d <= L) { add(g[p][c + 1][new_s + 2 * d], f[p][c][s] * (c + 1 - p) % mod); } if (0 <= new_s && new_s <= L) { add(g[p][c][new_s], f[p][c][s] * (2 * c - p) % mod); } if (c - 1 >= 1 && 0 <= new_s - 2 * d && new_s - 2 * d <= L) { add(g[p][c - 1][new_s - 2 * d], f[p][c][s] * (c - 1) % mod); } } if (p < 2) { if (c + 1 <= N && 0 <= new_s + d && new_s + d <= L) { add(g[p + 1][c + 1][new_s + d], f[p][c][s] * (2 - p) % mod); } if (0 <= new_s - d && new_s - d <= L) { add(g[p + 1][c][new_s - d], f[p][c][s] * (2 - p) % mod); } } } } } f.swap(g); } i64 ans = 0; for (int l = 0; l <= L; ++l) { add(ans, f[2][1][l]); } cout << ans << "\n"; return 0; }

Compilation message (stderr)

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:42:10: error: missing template arguments before 'f'
   42 |   vector f(3, vector(N + 1, vector<i64>(L + 1)));
      |          ^
skyscraper.cpp:43:3: error: 'f' was not declared in this scope
   43 |   f[0][0][0] = 1;
      |   ^
skyscraper.cpp:45:12: error: missing template arguments before 'g'
   45 |     vector g(3, vector(N + 1, vector<i64>(L + 1)));
      |            ^
skyscraper.cpp:53:19: error: 'g' was not declared in this scope
   53 |               add(g[p][c + 1][new_s + 2 * d], f[p][c][s] * (c + 1 - p) % mod);
      |                   ^
skyscraper.cpp:56:19: error: 'g' was not declared in this scope
   56 |               add(g[p][c][new_s], f[p][c][s] * (2 * c - p) % mod);
      |                   ^
skyscraper.cpp:59:19: error: 'g' was not declared in this scope
   59 |               add(g[p][c - 1][new_s - 2 * d], f[p][c][s] * (c - 1) % mod);
      |                   ^
skyscraper.cpp:64:19: error: 'g' was not declared in this scope
   64 |               add(g[p + 1][c + 1][new_s + d], f[p][c][s] * (2 - p) % mod);
      |                   ^
skyscraper.cpp:67:19: error: 'g' was not declared in this scope
   67 |               add(g[p + 1][c][new_s - d], f[p][c][s] * (2 - p) % mod);
      |                   ^
skyscraper.cpp:73:12: error: 'g' was not declared in this scope
   73 |     f.swap(g);
      |            ^