Submission #164670

# Submission time Handle Problem Language Result Execution time Memory
164670 2019-11-22T12:56:26 Z aggu_01000101 Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
using namespace std;
vector<int> find_subset(int l, int u, vector<int> arr){
    vector<pair<int, int>> arr1;
    for(int i = 0;i<arr.size();i++){
        arr1.push_back(make_pair(arr[i], i));
    }
    sort(arr1.begin(), arr1.end());
    vector<int> answer;
    int first = 0, last = 1;
    int sum = 0;
    while(last<=arr1.size() && first<arr.size()){
        if(sum>=l && sum<=u){
            for(int i = first;i<last;i++){
                answer.push_back(arr1[i].second+1);
            }
            goto returnanswer;
        }
        else if(sum<l){
            if(last<arr1.size()) sum+=arr1[last].first;
            last++;
        }
        else{
            sum-=arr1[first].first;
            first++;
        }
    }
    returnanswer:
    return answer;
}

Compilation message

molecules.cpp: In function 'std::vector<long long int> find_subset(long long int, long long int, std::vector<long long int>)':
molecules.cpp:8:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<arr.size();i++){
                   ~^~~~~~~~~~~
molecules.cpp:15:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(last<=arr1.size() && first<arr.size()){
           ~~~~^~~~~~~~~~~~~
molecules.cpp:15:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(last<=arr1.size() && first<arr.size()){
                                ~~~~~^~~~~~~~~~~
molecules.cpp:23:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(last<arr1.size()) sum+=arr1[last].first;
                ~~~~^~~~~~~~~~~~
/tmp/ccxbbyZP.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