답안 #28018

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28018 2017-07-14T18:49:29 Z repeating Detecting Molecules (IOI16_molecules) C++11
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "molecules.h"
#define F first
#define S second
#define P push
#define pb push_back
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define W while
#define R return
#define C continue
#define SI size()
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define SF(x) scanf("%I64d",&x)
#define SF2(x,y) scanf("%I64d%I64d",&x,&y)
#define SF3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z)
#define SF4(x,y,z,o) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&o)
#define all(v) v.begin(),v.end()

using namespace std;
const long long INF = 1e9;
const int MX=1000005;

vector<int> r1,r2;
vector<int> res;
vector< pair<int,int> > v;
vector<int> find_subset(int l, ll u, vector<int> w) {
    for(int i=0;i<w.SI;i++){
        v.pb({w[i],i});
    }
    sort(all(v));
    ll sum=0;
    for(int i=w.SI-1;sum<l&&i>=0;i--){
        sum+=v[i].F;
        r1.pb(v[i].S);
    }
    for(int i=0;i<w.SI-r1.SI;i++){
        r2.pb(v[i].S);
    }
    reverse(all(r2));
    reverse(all(r1));
    W(sum>u){
        if(r1.empty()||r2.empty())R vector<int>(0);
        sum-=w[r1.back()];
//        cout<<r1.back()<<" ";
        r1.pop_back();
        res.pb(r2.back());
        sum+=w[r2.back()];
//        cout<<r2.back()<<endl;
        r2.pop_back();
    }
    if(sum<l)R vector<int>(0);
    W(!r1.empty()){
        res.pb(r1.back());
        r1.pop_back();
    }
    return res;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, long long int, std::vector<int>)':
molecules.cpp:30:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<w.SI;i++){
                  ^
molecules.cpp:39:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<w.SI-r1.SI;i++){
                  ^
/tmp/ccMAkOeb.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