Submission #335150

#TimeUsernameProblemLanguageResultExecution timeMemory
335150blueDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include "molecules.h"
#include <vector>
#include <algorithm>
using namespace std;

vector<long long> W(200001);
int n;

vector<int> find_subset(int l, int u, vector<int> w)
{
    n = w.size();

    int i, x;
    for(i = 0; i < n; i++) W[i] = w[i];

    vector<int> I(n);
    for(i = 0; i < n; i++) I[i] = i;

    sort(I.begin(), I.end(), [] (int x, int y)
    {
        return W[x] < W[y];
    });

    vector<long long> res;

    long long a = 0, b = -1;
    long long sum = 0;
    while(1)
    {
        if(sum < l)
        {
            if(b == n-1) return res;
            else
            {
                b++;
                sum += W[I[b]];
            }
        }
        else if(sum > u)
        {
            a++;
            sum -= W[I[a-1]];
        }
        else
        {
            for(x = a; x <= b; x++) res.push_back(I[x]);
            return res;
        }
    }
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:32:33: error: could not convert 'res' from 'vector<long long int>' to 'vector<int>'
   32 |             if(b == n-1) return res;
      |                                 ^~~
      |                                 |
      |                                 vector<long long int>
molecules.cpp:47:20: error: could not convert 'res' from 'vector<long long int>' to 'vector<int>'
   47 |             return res;
      |                    ^~~
      |                    |
      |                    vector<long long int>