제출 #867495

#제출 시각아이디문제언어결과실행 시간메모리
867495lolismekDetecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
#include "molecules.h" #include <algorithm> #include <iostream> #include <queue> #include <cassert> using namespace std; vector<int> find_subset(int l, int u, vector<int> w){ queue <int> dq; long long sum = 0; vector <pii> v; for(int i = 0; i < (int)w.size(); i++){ v.push_back({w[i], i}); } sort(w.begin(), w.end()); sort(v.begin(), v.end()); for(int i = 0; i < (int)w.size(); i++){ sum += w[i]; dq.push(i); while(!dq.empty() && sum > u){ sum -= w[dq.front()]; dq.pop(); } if(l <= sum && sum <= u){ vector <int> ans; while(!dq.empty()){ ans.push_back(v[dq.front()].second); dq.pop(); } return ans; } } return {}; } /* 4 15 17 6 8 8 7 */

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:14:13: error: 'pii' was not declared in this scope
   14 |     vector <pii> v;
      |             ^~~
molecules.cpp:14:16: error: template argument 1 is invalid
   14 |     vector <pii> v;
      |                ^
molecules.cpp:14:16: error: template argument 2 is invalid
molecules.cpp:16:11: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   16 |         v.push_back({w[i], i});
      |           ^~~~~~~~~
molecules.cpp:20:12: error: request for member 'begin' in 'v', which is of non-class type 'int'
   20 |     sort(v.begin(), v.end());
      |            ^~~~~
molecules.cpp:20:23: error: request for member 'end' in 'v', which is of non-class type 'int'
   20 |     sort(v.begin(), v.end());
      |                       ^~~
molecules.cpp:34:32: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   34 |                 ans.push_back(v[dq.front()].second);
      |                                ^