제출 #853068

#제출 시각아이디문제언어결과실행 시간메모리
853068_uros9Detecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define endl '\n' #define int long long using namespace std; const long long longlongmax=9223372036854775807; const int modul=998244353; const long long mod = 1e9 + 7; vector<int> find_subset(int l,int u,vector<int> w){ int n=w.size(); vector<int> rez(0); vector<pair<int,int>> niz(n); for(int i=0; i<n; i++) niz[i]={w[i],i}; sort(niz.begin(),niz.end()); if(niz[0].first>u) return rez; vector<int> pref(n+1,0); for(int i=0; i<n; i++){ pref[i+1]=pref[i]; pref[i+1]+=niz[i].first; } bool ok=false; int ll,dd; pref.push_back(1e15); /*for(auto x:pref) cout << x << " "; cout << endl;*/ for(int i=0; i<n&&!ok; i++){ int ind=lower_bound(pref.begin(),pref.end(),pref[i]+l)-pref.begin(); //cout << pref[i] << " " << pref[ind] << endl; if(pref[ind]-pref[i]>u) continue; ok=true; ll=i; dd=ind; } if(!ok) return rez; for(int i=ll; i<=dd-1; i++) rez.push_back(niz[i].second); /*for(auto x:rez) cout << x << " ";*/ return rez; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); //freopen("factory.in","r",stdin); //freopen("factory.out","w",stdout); int n,l,u; cin >> n >> l >> u; vector<int> w(n); for(auto&x:w) cin >> x; vector<int> rez=find_subset(l,u,w); for(auto x:rez) cout << x << " "; cout << endl; return 0; } /* abcde 01234 04321 --> 12340 0 1 011 110 */

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

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