답안 #249810

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
249810 2020-07-15T19:37:12 Z hhh07 Detecting Molecules (IOI16_molecules) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <set>
#include <cmath>
#include <climits>
#include <cstring>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
 
vi find_subset(ll l, ll u, vi w){
    vi result;
    ll n = w.size();
    ii x[n];
    for (ll i = 0; i < n; i++)
        x[i] = {w[i], i};
    sort(x, x + n);
    
    ll s = 0, curr = 0;
    bool t = false;
    for (ll i = 0; i < n; i++){
        w[i] = x[i].first;
        s += w[i];
        curr = i;
        if (s >= l && s <= u){
            for (ll j = 0; j <= i; j++)
                result.push_back(x[j].second);
            return result;
        }
        if (s >= l){
            s -= w[i];
            t = true;
            break;
        }
    }
    if (!t)
      return result;
    for (ll i = curr; i < n; i++){
        w[i] = x[i].first;
        s += w[i] - w[i - curr];
        if (s >= l && s <= u){
            for (ll j = i - curr + 1; j <= i; j++)
                result.push_back(x[j].second);
            return result;
        }
    }
    return result;
}

Compilation message

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