Submission #169964

#TimeUsernameProblemLanguageResultExecution timeMemory
169964whtttDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #define ll long long using namespace std; ll* find_subset(ll l, ll u, vector<ll> w){ ll sum = 0; vector<ll> returnThis; sort(w.begin(), w.end()); for(ll i = 0;i < w.size();i++){ sum += w[i]; if(sum <= u && sum >= l){ for(ll j = 0;j <= i;j++){ returnThis.push_back(w[i]); } return &returnThis[0]; } else if(sum > l){ sum -= w[i]; for(ll j = i;j < w.size();j++){ sum += w[j]-w[j-i]; if(sum <= u && sum >= l){ for(ll j = 0;j <= i;j++){ returnThis.push_back(w[i]); } return &returnThis[0]; } if(j == w.size()-1){ return {}; } } } } return {}; }

Compilation message (stderr)

molecules.cpp: In function 'long long int* find_subset(long long int, long long int, std::vector<long long int>)':
molecules.cpp:12:5: error: 'sort' was not declared in this scope
     sort(w.begin(), w.end());
     ^~~~
molecules.cpp:12:5: note: suggested alternative: 'qsort'
     sort(w.begin(), w.end());
     ^~~~
     qsort
molecules.cpp:13:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(ll i = 0;i < w.size();i++){
                  ~~^~~~~~~~~~
molecules.cpp:22:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(ll j = i;j < w.size();j++){
                          ~~^~~~~~~~~~
molecules.cpp:30:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(j == w.size()-1){
                    ~~^~~~~~~~~~~~~