제출 #987274

#제출 시각아이디문제언어결과실행 시간메모리
987274normankr07Detecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include "molecules.h" std::vector<int> find_subset(int l, int u, std::vector<int> w) { // for (int i = 1; i <= n; i++) // { // if (l <= w[i - 1] && w[i - 1] <= u) // { // return vector<int>(i); // } // } vector<pair<int, int>> ww; ll sum = 0; for (int i = 0; i < n; i++) { sum += w[i]; ww.push_back(make_pair(w[i], i)); } sort(ww.begin(), ww.end()); vector<int> id; for (int i = n - 1, j = n; i < j && i >= -1;) { while (sum > u && i >= 0) { sum -= ww[i].first; i--; } if (l <= sum && sum <= u) { for (int p = 0; p <= i; p++) id.push_back(ww[p].second); for (int p = j; p < n; p++) id.push_back(ww[p].second); return id; } j--; sum += ww[j].first; } return vector<int>(); }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:5: error: 'vector' was not declared in this scope
   12 |     vector<pair<int, int>> ww;
      |     ^~~~~~
molecules.cpp:12:5: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
molecules.cpp:12:12: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   12 |     vector<pair<int, int>> ww;
      |            ^~~~
      |            std::pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
molecules.cpp:12:17: error: expected primary-expression before 'int'
   12 |     vector<pair<int, int>> ww;
      |                 ^~~
molecules.cpp:13:5: error: 'll' was not declared in this scope; did you mean 'l'?
   13 |     ll sum = 0;
      |     ^~
      |     l
molecules.cpp:14:25: error: 'n' was not declared in this scope
   14 |     for (int i = 0; i < n; i++)
      |                         ^
molecules.cpp:16:9: error: 'sum' was not declared in this scope
   16 |         sum += w[i];
      |         ^~~
molecules.cpp:17:9: error: 'ww' was not declared in this scope; did you mean 'w'?
   17 |         ww.push_back(make_pair(w[i], i));
      |         ^~
      |         w
molecules.cpp:17:22: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
   17 |         ww.push_back(make_pair(w[i], i));
      |                      ^~~~~~~~~
      |                      std::make_pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:567:5: note: 'std::make_pair' declared here
  567 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
molecules.cpp:19:10: error: 'ww' was not declared in this scope; did you mean 'w'?
   19 |     sort(ww.begin(), ww.end());
      |          ^~
      |          w
molecules.cpp:19:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   19 |     sort(ww.begin(), ww.end());
      |     ^~~~
      |     short
molecules.cpp:20:12: error: expected primary-expression before 'int'
   20 |     vector<int> id;
      |            ^~~
molecules.cpp:21:18: error: 'n' was not declared in this scope
   21 |     for (int i = n - 1, j = n; i < j && i >= -1;)
      |                  ^
molecules.cpp:21:36: error: 'j' was not declared in this scope
   21 |     for (int i = n - 1, j = n; i < j && i >= -1;)
      |                                    ^
molecules.cpp:23:16: error: 'sum' was not declared in this scope
   23 |         while (sum > u && i >= 0)
      |                ^~~
molecules.cpp:28:18: error: 'sum' was not declared in this scope
   28 |         if (l <= sum && sum <= u)
      |                  ^~~
molecules.cpp:31:17: error: 'id' was not declared in this scope; did you mean 'i'?
   31 |                 id.push_back(ww[p].second);
      |                 ^~
      |                 i
molecules.cpp:33:17: error: 'id' was not declared in this scope; did you mean 'i'?
   33 |                 id.push_back(ww[p].second);
      |                 ^~
      |                 i
molecules.cpp:34:20: error: 'id' was not declared in this scope; did you mean 'i'?
   34 |             return id;
      |                    ^~
      |                    i
molecules.cpp:37:9: error: 'sum' was not declared in this scope
   37 |         sum += ww[j].first;
      |         ^~~
molecules.cpp:39:19: error: expected primary-expression before 'int'
   39 |     return vector<int>();
      |                   ^~~
molecules.cpp:39:19: error: expected ';' before 'int'
   39 |     return vector<int>();
      |                   ^~~
      |                   ;
molecules.cpp:39:22: error: expected unqualified-id before '>' token
   39 |     return vector<int>();
      |                      ^