Submission #678894

#TimeUsernameProblemLanguageResultExecution timeMemory
678894Genius3435Detecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using u32 = uint32_t; int[] find_subset(int l, int u, int[] _w) { int const n = sizeof(w)/sizeof(int); deque<pair<u32, int>> w, used; for (int i = 0; i < n; ++i) { w.emplace_back(_w[i], i); } sort(w.begin(), w.end()); u32 s = 0; while (s < l && !w.empty()) { auto const [x, i] = w.front(); if (s+x > u) break; w.pop_front(); used.emplace_back(x, i); s += x; } while (s < l && !w.empty()) { auto const [x, i] = used.front(); auto const [y, j] = w.back(); s -= x, s += y; used.pop_front(); w.pop_back(); used.emplace_back(y, j); } if (l <= s && s <= u) { int *ans = new int[used.size()], j = 0; for (auto const &[x, i] : used) ans[j++] = i; return ans; } else { int *ans = new int[0]; return ans; } }

Compilation message (stderr)

molecules.cpp:5:4: error: structured binding declaration cannot have type 'int'
    5 | int[] find_subset(int l, int u, int[] _w) {
      |    ^~
molecules.cpp:5:4: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
molecules.cpp:5:4: error: empty structured binding declaration
molecules.cpp:5:7: error: expected initializer before 'find_subset'
    5 | int[] find_subset(int l, int u, int[] _w) {
      |       ^~~~~~~~~~~