제출 #529862

#제출 시각아이디문제언어결과실행 시간메모리
529862__VariattoDetecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define ll long long
const ll MAX=2e5+10;
pair<ll,ll>t[MAX];
ll n, u, l;
vector<ll>v;
ll pref[MAX], suf[MAX];
vector<ll> znajdz(ll k){
    ll sum=pref[k];
    vector<ll>wy;
    for(ll i=0; i<k; i++)
        wy.pb(t[i].se);
    if(sum>=l && sum<=u)
        return wy;
    for(ll i=0; i<k; i++){
        sum-=t[i].fi, sum+=t[n-i-1].fi;
        wy[i]=t[n-i-1].se;    
        if(sum>=l && sum<=u)
            return wy;
    }
    return wy;
}
vector<ll> find_subset(ll l, ll u, vector<ll>w){
    ll n=w.size();
    for(ll i=0; i<n; i++){
        t[i].fi=w[i];
        t[i].se=i;
    }
    sort(t, t+n);
    for(ll i=0; i<n; i++){
        pref[i]=t[i].fi;
        if(i)
            pref[i]+=pref[i-1];
    }
    vector<ll>wy;
    for(ll i=n-1; i>=0; i--)
        suf[i]=suf[i+1]+t[i].fi;
    for(ll k=1; k<=n; k++){
        if(pref[k-1]<=u && suf[n-k]>=l){
            wy=znajdz(k);
            sort(wy.begin(), wy.end());
            return wy;
        }
    }
    return wy;
}
/*int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin>>n>>l>>u;
    vector<ll>x;
    for(ll i=1; i<=n; i++){
        ll c=0;
        cin>>c;
        x.pb(c);
    }
    vector<ll>xd=find_subset(l, u, x);
    for(auto a:xd)
        cout<<a<<" ";
    cout<<"\n";

}*/

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

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