Submission #784952

#TimeUsernameProblemLanguageResultExecution timeMemory
784952BoasDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include "molecules.h"

using namespace std;
#include <bits/stdc++.h>

#include "grader.cpp"

#define MAX_N 200001

typedef vector<int> vi;

int L{};
int U{};

int n{};

vi mols;

vi addMolecule(const int &w, const bitset<MAX_N> &used)
{
    for (int i = 0; i < n; i++)
    {
        int nw = w + mols[i];
        if (nw > U)
            continue;
        if (used[i])
            continue;
        if (nw >= L)
        {
            vi solution = {i};
            for (int i = 0; i < mols.size(); i++)
            {
                if (used[i])
                    solution.push_back(i);
            }
            return solution;
        }
        bitset<MAX_N> newUsed(used);
        newUsed[i] = true;
        auto ret = addMolecule(nw, newUsed);
        if (ret.size() > 0)
            return ret;
    }
    return {};
}

vi find_subset(int l, int u, vi w)
{
    L = l;
    U = u;
    mols = w;
    n = w.size();
    return addMolecule(0, {});
}

Compilation message (stderr)

molecules.cpp: In function 'vi addMolecule(const int&, const std::bitset<200001>&)':
molecules.cpp:31:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |             for (int i = 0; i < mols.size(); i++)
      |                             ~~^~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccDyLAiS.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccl7VBpU.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status