Submission #265744

# Submission time Handle Problem Language Result Execution time Memory
265744 2020-08-15T04:36:27 Z amalla Detecting Molecules (IOI16_molecules) C++17
Compilation error
0 ms 0 KB
#include "molecules.h"
#include<bits/stdc++.h>

using namespace std;

#define ll long long

vector<int> find_subset(int l, int u, vector<int> w) {
    int N = w.size();
    pair<int,int> A[N-1];
    for (int i = 0; i<N; ++i) {
        A[i].first = w[i]; A[i].second = i;
    }
    sort(A, A);
    ll prefix[N]; prefix[0] = 0;
    for (int i = 1; i<=N; ++i) prefix[i] = prefix[i-1] + A[i-1].first;

    int i = 0, j = 1;
        while (true) {
            if (prefix[j]-prefix[i]<l) {
                ++j;
                if (j>N) break;
            }
            else if (prefix[j]-prefix[i]>u) {
                ++i;
                while (i>=j) {
                    ++j;
                    if (j>N) break;
                }
            }
            else {
                vector<int> Ans(j-i);
                int k = 0;
                while(i<=j) {
                    ++i;
                    Ans[k] = A[i].second;
                }
                return Ans;
            }
        }
    }

    return {0};
}

Compilation message

molecules.cpp:43:5: error: expected unqualified-id before 'return'
   43 |     return {0};
      |     ^~~~~~
molecules.cpp:44:1: error: expected declaration before '}' token
   44 | }
      | ^
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:41:5: warning: control reaches end of non-void function [-Wreturn-type]
   41 |     }
      |     ^