Submission #1132205

#TimeUsernameProblemLanguageResultExecution timeMemory
1132205lopkusDetecting Molecules (IOI16_molecules)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

#define int long long

#include "molecules.h"

using namespace std;

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    vector<pair<int,int>> V;
    int n = w.size();
    for(int i = 0; i < n; i++) {
        V.push_back({w[i], i});
    }
    sort(V.begin(), V.end());
    int i = 0, j = 0;
    int x = 0;
    while(i < n && j < n) {
        if(x >= l && x <= u) {
            break;
        }
        if(x < l && j < n - 1) {
            if(j + 1 == n) {
                break;
            }
            j++;
            x += V[j].first;
        }
        else {
            x -= V[i].first;
            i++;
        }
    }
    vector<int> ans;
    if(x >= l && x <= u) {
        for(int q = i; q <= j; q++) {
            ans.push_back(V[q].second);
        }
    }
    sort(ans.begin(), ans.end());
    return ans;
}

Compilation message (stderr)

molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
/usr/bin/ld: /tmp/ccHy3wb5.o: in function `main':
grader.cpp:(.text.startup+0x173): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status