답안 #276679

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
276679 2020-08-20T15:04:51 Z ajpiano Detecting Molecules (IOI16_molecules) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))
#define all(x) x.begin(), x.end()

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int find_subset(int d, int u, int w[], int n, int result[]){
    vector<pair<ll,int>> w2(n);
    FOR(i,n) w2[i].f = w[i];
    FOR(i,n) w2[i].s = i+1;
    sort(all(w2));
    int l = 0, r = 0;
    ll total = 0;
    for(; l < n; l++){
        if(r < l){
            total = 0;
            r = l;
        }else if(l != 0) total -= w2[l-1].f;
        for(; total+w2[r].f <= u; r++) total += w2[r].f;
        if(total >= d) break;
    }
    if(l == r){
        return 0;
    }else{
        FOR(i,r-l) result[i] = w2[l+i].s;
        return r-l;
    }
}

void testf(){
    int n,l,u;
    cin >> n >> l >> u;
    int w[n]; FOR(i,n) cin >> w[i];
    int ans[n];
    int m = find_subset(l,u,w,n,ans);
    cout << m << "\n";
    FOR(i,m) cout << ans[i] << " ";
    cout << "\n";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
//    testf();
    return 0;
}

Compilation message

/tmp/ccYzfEyx.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccKR6NBr.o:molecules.cpp:(.text.startup+0x0): first defined here
/tmp/ccYzfEyx.o: In function `main':
grader.cpp:(.text.startup+0x12b): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status