제출 #1369005

#제출 시각아이디문제언어결과실행 시간메모리
1369005kismisDetecting Molecules (IOI16_molecules)C++20
컴파일 에러
0 ms0 KiB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;

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

    // Sort indices by weight
    vector<int> idx(n);
    iota(idx.begin(), idx.end(), 0);
    sort(idx.begin(), idx.end(), [&](int a, int b) {
        return w[a] < w[b];
    });

    // Feasibility check: total sum must reach l
    long long total = 0;
    for (int i : idx) total += w[i];
    if (total < l) return {};

    // Greedy prefix sum
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        sum += w[idx[i]];
        if (sum >= l) {
            // By the problem guarantee, sum <= u holds here
            return vector<int>(idx.begin(), idx.begin() + i + 1);
        }
    }

    return {}; // unreachable if feasibility check passed
}

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/cc4aJn5Z.o: in function `main':
grader.cpp:(.text.startup+0x165): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status