Submission #269162

#TimeUsernameProblemLanguageResultExecution timeMemory
269162Bill_00Detecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; pair<int,int>p[200001]; std::vector<int> find_subset(int l, int u, std::vector<int> w){ for(int i=0;i<w.size();i++){ p[i]=make_pair(w[i],i); } sort(p,p+w.size()); vector<int>res; int sum=0,up=-1; for(int i=0;i<w.size();i++){ sum+=p[i].first; if(sum<=u && sum>=l){ for(int j=0;j<=i;j++){ res.push_back(p[i].second); } sort(res.begin(),res.end()); return res; } if(sum>=l){ up=i-; sum-=p[i].first; break; } } if(up==-1){ return res; } for(int i=up;i>=0;i--){ sum-=p[i].first; sum+=p[i+n-up-1].first; if(sum>=l && sum<=u){ for(int j=0;j<=i-1;j++){ res.push_back(p[j].second); } for(int j=i+n-up-1;j<n;j++){ res.push_back(p[j].second); } sort(res.begin(),res.end()); return res; } } return res; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:6:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 |  for(int i=0;i<w.size();i++){
      |              ~^~~~~~~~~
molecules.cpp:12:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(int i=0;i<w.size();i++){
      |                 ~^~~~~~~~~
molecules.cpp:22:9: error: expected primary-expression before ';' token
   22 |    up=i-;
      |         ^
molecules.cpp:32:12: error: 'n' was not declared in this scope
   32 |   sum+=p[i+n-up-1].first;
      |            ^