Submission #307263

# Submission time Handle Problem Language Result Execution time Memory
307263 2020-09-27T13:35:50 Z mihai145 Detecting Molecules (IOI16_molecules) C++14
0 / 100
81 ms 65540 KB
#include "molecules.h"
#include <vector>
#include <bitset>

const int DIM = 30 * 8388608; ///2^23
std::bitset <DIM> s;

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    std::vector <int> ans;

    s[0] = 1;

    for(auto it : w)
        s |= (s << it);

    int p = -1;
    for(int pos = l; pos <= u; pos++)
        if(s[pos] == 1)
            {
                p = pos;
                break;
            }

    if(p == -1)
        return ans;

    int pointerW = (int)w.size() - 1;

    while(p > 0)
        {
            while(pointerW >=0 && (p - w[pointerW] < 0 || s[p - w[pointerW]] != 1))
                pointerW--;

            if(pointerW >= 0) {
                ans.push_back(pointerW);
                p -= w[pointerW];
                pointerW--;
            }
        }

    return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 81 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 75 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 81 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 81 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 81 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 81 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -