제출 #380140

#제출 시각아이디문제언어결과실행 시간메모리
380140vishesh312Detecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
//#include"molecules.h" #include"bits/stdc++.h" using namespace std; using ll = long long; vector<int> find_subset(int l, int u, vector<int> w) { vector<pair<ll, int>> v; for (int i = 0; i < (int)w.size(); ++i) { v.push_back({w[i], i}); } int n = w.size(); sort(v.begin(), v.end()); ll sum = 0; int i = 0; while (sum < l) { sum += v[i].first; ++i; } int end = i; i = 0; while (sum > u and !dq.empty()) { sum -= v[i].first; ++i; } vector<int> ret; for (; i < end; ++i) { ret.push_back(v[i].second); } sort(ret.begin(), ret.end()); bool fsum = (sum >= l and sum <= u); i = n-1; sum = 0; while (sum < l) { sum += v[i].first; --i; } end = i; i = n-1; while (sum > u) { sum -= v[i].first; --i; } vector<int> r2; for (; i > end; --i) { r2.push_back(v[i].second); } sort(r2.begin(), r2.end()); if (fsum) return ret; return r2; } int main() { int l, r, n; cin >> l >> r >> n; vector<int> v(n); for (auto &x : v) cin >> x; v = find_subset(l, r, v); for (auto x : v) cout << x << " "; }

컴파일 시 표준 에러 (stderr) 메시지

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:21:25: error: 'dq' was not declared in this scope
   21 |     while (sum > u and !dq.empty()) {
      |                         ^~