Submission #1299610

#TimeUsernameProblemLanguageResultExecution timeMemory
1299610alexiahDetecting Molecules (IOI16_molecules)C++20
Compilation error
0 ms0 KiB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;

vector<long long> find_subset(long long l, long long u, vector<long long> w) {
    long long n = w.size();
    vector<pair<long long , long long>> v(n);
    for(long long i = 0; i < n; i++){
        v[i].first = w[i]; v[i].second = i;
    }
    sort(v.begin() , v.end());
    long long count = v[0].first;
    long long ini = 0 , fin = 0;
    while(true){
        if(ini > fin){
            fin++; count += v[fin].first;
        }
        if(count > u){
            count -= v[ini].first; ini++;
        }
        else if(count < l){
            fin++;
            if(fin >= n){
                return {};
            }
            count += v[fin].first;
        }
        if(count >= l && count <= u){
            vector<long long> ans;
            for(; ini <= fin; ini++) ans.push_back(v[ini].second);
            return ans;
        }
    }
    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/ccFtWom1.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