Submission #169965

# Submission time Handle Problem Language Result Execution time Memory
169965 2019-12-23T12:56:04 Z whttt Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB

#include <iostream>
#include <vector>
#include <algorithm>
#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

molecules.cpp: In function 'long long int* find_subset(long long int, long long int, std::vector<long long int>)':
molecules.cpp:14:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(ll i = 0;i < w.size();i++){
                  ~~^~~~~~~~~~
molecules.cpp:23:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(ll j = i;j < w.size();j++){
                          ~~^~~~~~~~~~
molecules.cpp:31:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(j == w.size()-1){
                    ~~^~~~~~~~~~~~~
/tmp/ccYJdqMm.o: In function `main':
grader.cpp:(.text.startup+0x152): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status