답안 #307262

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
307262 2020-09-27T13:35:21 Z mihai145 Detecting Molecules (IOI16_molecules) C++14
0 / 100
97 ms 65540 KB
#include "molecules.h"
#include <vector>
#include <bitset>

const int DIM = 60 * 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;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 95 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 97 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 95 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 95 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 95 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 95 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -