제출 #501449

#제출 시각아이디문제언어결과실행 시간메모리
501449MurotYDetecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define ll int #define ff first #define ss second using namespace std; const int N=1e6+7; ll a[N], b[N], sum=0; bool dp[N]; vector <ll> v[N]; ll mp[N], mp1[N]; bool knapSack(ll n, ll k){ memset(dp, 0, sizeof(dp)); dp[0]=1; for (int i=1;i<=900;i++) v[i].push_back(i); for (int i=1;i<=n;i++){ for (int j=sum;j>=0;j--){ if (a[i]+j <= sum and dp[a[i]+j] == 0) { dp[a[i]+j] |= dp[j]; if (dp[a[i]+j] and mp[a[i]+j] == 0) { for (auto it:v[j]) v[j+a[i]].push_back(it); if (j != 0) for (auto it:v[a[i]]) v[j+a[i]].push_back(it); } } } } /* cout << dp[k] <<" "; for (int i=1;i<=11;i++) { for (auto it:v[i]) cout << it <<" "; cout <<"\n"; }*/ return dp[k]; } int main() { ll n, k; cin >> n >> k; for (int i=1;i<=n;i++) cin >> a[i], sum+=a[i], mp[a[i]]++, mp1[a[i]]=i; sort(a+1,a+n+1); if (knapSack(n, k) == 0) cout << "no"; else { for (auto it:v[k]) if (mp1[it] > 0) cout << mp1[it]-1 <<" "; } }

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

/usr/bin/ld: /tmp/cc92d0sY.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccoAsWMZ.o:molecules.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc92d0sY.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