Submission #249805

# Submission time Handle Problem Language Result Execution time Memory
249805 2020-07-15T19:11:34 Z hhh07 Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <set>
#include <cmath>
#include <climits>
#include <cstring>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;

vi find_subset(int l, int u, vi w){   
    vi result;
    int n = w.size();
    ii x[n];
    for (int i = 0; i < n; i++)
        x[i] = {w[i], i};
    sort(x, x + n);
    
    int s = 0, curr = 0;
    for (int i = 0; i < n; i++){
        w[i] = x[i].first;
        s += w[i];
        curr = i;
        if (s >= l && s <= u){
            for (int j = 0; j <= i; j++)
                result.push_back(x[j].second);
            return;
        }
        if (s >= l){
            s -= w[i];
            break;
        }
    }
    
    for (int i = curr; i < n; i++){
        w[i] = x[i].first;
        s += w[i] - w[i - curr];
        if (s >= l && s <= u){
            for (int j = i - curr + 1; j <= i; j++)
                result.push_back(x[j].second);
            break;
        }
    }
    return result;
}

Compilation message

molecules.cpp: In function 'vi find_subset(int, int, vi)':
molecules.cpp:33:13: error: return-statement with no value, in function returning 'vi {aka std::vector<int>}' [-fpermissive]
             return;
             ^~~~~~