Submission #472912

#TimeUsernameProblemLanguageResultExecution timeMemory
472912Erik_GepardDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int ll, int uu, std::vector<int> w) { int n=w.size(); int l=ll; int u=uu; vector<pair<int, int> > a(w.size()); for(int i=0; i<w.size(); i++){ a[i].first=w[i]; a[i].second=i; } sort(a.begin(), a.end()); int sum=0; int j=0; int helyesi=-1, helyesj=-1; for(int i=0; i<n; i++){ while(j<n && sum+a[j].first<=u){ sum+=a[j].first; j++; } if(sum>=l){ for(int q=i; q<j; q++){ ans.push_back(a[q].second); } return ans; } sum-=a[i].first; } return vector<int>(0); }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:11:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i=0; i<w.size(); i++){
      |                  ~^~~~~~~~~
molecules.cpp:26:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   26 |               ans.push_back(a[q].second);
      |               ^~~
      |               abs
molecules.cpp:28:20: error: 'ans' was not declared in this scope; did you mean 'abs'?
   28 |             return ans;
      |                    ^~~
      |                    abs
molecules.cpp:18:9: warning: unused variable 'helyesi' [-Wunused-variable]
   18 |     int helyesi=-1, helyesj=-1;
      |         ^~~~~~~
molecules.cpp:18:21: warning: unused variable 'helyesj' [-Wunused-variable]
   18 |     int helyesi=-1, helyesj=-1;
      |                     ^~~~~~~