Submission #1268434

#TimeUsernameProblemLanguageResultExecution timeMemory
1268434MahogDetecting Molecules (IOI16_molecules)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "molecules.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, greater<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
const int MAX = 2e5 + 2;
ll id[MAX], a[MAX], n;

bool cmp(int x, int y) {
    return a[x] > a[y];
}

vector<int> find_subset(ll l, ll r, vector<ll> w) {
    n = w.size();
    for (int i = 1; i <= n; i++) {
        id[i] = i;
        a[i] = w[i - 1];
    }
    sort(id + 1, id + n + 1, cmp);
    ll total = 0;
    int temp = 0;
    for (int i = 1; i <= n; i++) {
        total += a[id[i]];
        if (total >= l) {
            temp = i;
            break;
        }
    }
    vector<int> res;
    if (temp == 0) return res;
    total = 0;
    for (int i = n - temp + 1; i <= n; i++) {
        res.push_back(id[i] - 1);
        total += a[id[i]];
    }
    for (int i = 0; i < temp; i++) {
        if (total >= l && total <= r) return res;
        total += a[id[i + 1]] - a[res[i] + 1];
        res[i] = id[i + 1];
    }
    return {};
}

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/ccPUcqd7.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