Submission #1282089

#TimeUsernameProblemLanguageResultExecution timeMemory
1282089lukasuliashviliFestival (IOI25_festival)C++20
Compilation error
0 ms0 KiB
#include <vector> #include <algorithm> using namespace std; vector<int> max_coupons(int A, vector<int> P, vector<int> T) { int N = P.size(); bool all_one = true; for (int t : T) { if (t != 1) { all_one = false; break; } } if (all_one) { vector<pair<int, int>> items; for (int i = 0; i < N; ++i) items.emplace_back(P[i], i); sort(items.begin(), items.end()); vector<int> result; for (auto& [price, idx] : items) { if (A >= price) { A -= price; result.push_back(idx); } else { break; } } return result; } if (N <= 20) { vector<int> best_order; vector<int> perm(N); for (int i = 0; i < N; ++i) perm[i] = i; do { int tokens = A; vector<int> current; for (int i = 0; i < N; ++i) { int idx = perm[i]; if (tokens >= P[idx]) { tokens = (tokens - P[idx]) * T[idx]; current.push_back(idx); } else { break; } } if (current.size() > best_order.size()) { best_order = current; } } while (next_permutation(perm.begin(), perm.end())); return best_order; } vector<bool> used(N, false); vector<int> best_result; vector<int> path; function<void(int)> dfs = [&](int tokens) { if (path.size() > best_result.size()) { best_result = path; } for (int i = 0; i < N; ++i) { if (!used[i] && tokens >= P[i]) { used[i] = true; path.push_back(i); dfs((tokens - P[i]) * T[i]); path.pop_back(); used[i] = false; } } }; dfs(A); return best_result; }

Compilation message (stderr)

festival.cpp: In function 'std::vector<int> max_coupons(int, std::vector<int>, std::vector<int>)':
festival.cpp:65:5: error: 'function' was not declared in this scope
   65 |     function<void(int)> dfs = [&](int tokens) {
      |     ^~~~~~~~
festival.cpp:3:1: note: 'std::function' is defined in header '<functional>'; did you forget to '#include <functional>'?
    2 | #include <algorithm>
  +++ |+#include <functional>
    3 | 
festival.cpp:65:14: error: expected primary-expression before 'void'
   65 |     function<void(int)> dfs = [&](int tokens) {
      |              ^~~~
festival.cpp:80:5: error: 'dfs' was not declared in this scope
   80 |     dfs(A);
      |     ^~~