Submission #770620

#TimeUsernameProblemLanguageResultExecution timeMemory
770620BenmathDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
/*#include <cstdio> #include <vector> #include <cassert> */ /* #include<bits/stdc++.h> using namespace std; */ #include "molecules.h" std::vector<int> find_subset(int l, int u, std::vector<int> w) { long long int sum=0; vector<int>ans; for(int i=0;i<w.size();i++){ if(w[i]<=u){ sum=sum+w[i]; ans.push_back(i); } if(sum>=l and sum<=u){ break; } } if(sum>=l and sum<=u){ return ans; }else{ ans.clear(); return ans;} } /* int main() { int n, l, u; assert(3 == scanf("%d %d %d", &n, &l, &u)); std::vector<int> w(n); for (int i = 0; i < n; i++) assert(1 == scanf("%d", &w[i])); std::vector<int> result = find_subset(l, u, w); printf("%d\n", (int)result.size()); for (int i = 0; i < (int)result.size(); i++) printf("%d%c", result[i], " \n"[i == (int)result.size() - 1]); } */

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:4: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
   12 |    vector<int>ans;
      |    ^~~~~~
      |    std::vector
In file included from /usr/include/c++/10/vector:67,
                 from molecules.h:3,
                 from molecules.cpp:9:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: 'std::vector' declared here
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
molecules.cpp:12:11: error: expected primary-expression before 'int'
   12 |    vector<int>ans;
      |           ^~~
molecules.cpp:13:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |    for(int i=0;i<w.size();i++){
      |                ~^~~~~~~~~
molecules.cpp:16:9: error: 'ans' was not declared in this scope
   16 |         ans.push_back(i);
      |         ^~~
molecules.cpp:23:12: error: 'ans' was not declared in this scope
   23 |     return ans;
      |            ^~~
molecules.cpp:25:4: error: 'ans' was not declared in this scope
   25 |    ans.clear();
      |    ^~~