Submission #330562

#TimeUsernameProblemLanguageResultExecution timeMemory
330562IgorIAliens (IOI16_aliens)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "aliens.h" using namespace std; void solve(int g, vector<int> &l, vector<int> &r, vector<vector<long long> > &dp, int le_i, int ri_i, int le_p, int ri_p) { if (le_i > ri_i) return; int mid_i = (le_i + ri_i) / 2; int id = le_p; for (int p = le_p; p <= ri_p && p < i; p++) { long long res = dp[p][g - 1]; long long L = l[p], R = r[mid_i - 1], covto = -1; if (p) covto = r[p - 1]; if (covto < L) res += 1ll * (R - L + 1) * (R - L + 1); else res += 1ll * (R - L + 1) * (R - L + 1) - 1ll * (covto - L + 1) * (covto - L + 1); if (res < dp[mid_i][g]) { id = p; dp[mid_i][g] = res; } } solve(g, l, r, dp, le_i, mid_i - 1, le_p, id); solve(g, l, r, dp, mid_i + 1, ri_i, id, ri_p); } long long take_photos(int n, int m, int k, vector<int> l, vector<int> r) { vector<int> cv(m); for (int i = 0; i < m; i++) { cv[i] = i + 1; } for (int i = 0; i < n; i++) { int x = min(l[i], r[i]); int y = max(l[i], r[i]); cv[y] = min(cv[y], x); } l.clear(); r.clear(); for (int i = 0; i < m; i++) { if (cv[i] <= i) { while (l.size() && l.back() >= cv[i]) l.pop_back(), r.pop_back(); l.push_back(cv[i]), r.push_back(i); } } n = l.size(); const long long INFLL = 1e18; vector<vector<long long> > dp(n + 1, vector<long long>(k + 1, INFLL)); dp[0][0] = 0; for (int g = 1; g <= k; g++) { solve(g, l, r, dp, 1, n, 0, n); } return *min_element(dp[n].begin(), dp[n].end()); }

Compilation message (stderr)

aliens.cpp: In function 'void solve(int, std::vector<int>&, std::vector<int>&, std::vector<std::vector<long long int> >&, int, int, int, int)':
aliens.cpp:11:41: error: 'i' was not declared in this scope
   11 |     for (int p = le_p; p <= ri_p && p < i; p++)
      |                                         ^