제출 #574403

#제출 시각아이디문제언어결과실행 시간메모리
574403EliasDetecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #ifndef _DEBUG #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #include "molecules.h" #endif using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { n = w.size(); vector<pair<int, int>> a(n); for (int i = 0; i < n; i++) a[i] = {w[i], i}; sort(a.begin(), a.end()); if (a[0].first > u) return {}; if (a.back().first >= l && a.back().first <= u) return {n - 1}; if (a[0].first >= l && a[0].first <= u) return {0}; int i = 0; int sum = 0; for (int j = 0; j < n; j++) { sum += a[j].first; while (sum > u) { sum -= a[i].first; i++; } if (sum >= l) { vector<int> out; for (int k = i; k < j; k++) { out.push_back(a[k].first); } return out; } } return {}; } #ifdef _DEBUG signed main() { int n, l, u; cin >> n >> l >> u; vector<int> a(n); for (int &x : a) cin >> x; for (int x : find_subset(l, u, a)) cout << x << " "; } #endif

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:14:5: error: 'n' was not declared in this scope
   14 |     n = w.size();
      |     ^
molecules.cpp:26:22: error: could not convert '{<expression error>}' from '<brace-enclosed initializer list>' to 'std::vector<int>'
   26 |         return {n - 1};
      |                      ^
      |                      |
      |                      <brace-enclosed initializer list>