제출 #651353

#제출 시각아이디문제언어결과실행 시간메모리
651353pauloamedDetecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include "molecules.h" using namespace std; vector<int> find_subset(int l, int u, vector<int> w){ int n = w.size(); vector<pair<int,int>> W; for(int i = 0; i < n; ++i){ W.push_back({w[i], i}); } sort(W.begin(), W.end()); vector<int> ans; for(int i = 0; i < n; ++i){ int mini = W[i].first; int id_mini = W[i].second; int maxi = W.back().first; int id_maxi = W.back().second; if(mini > u) return {}; else if(mini >= l){ ans.push_back(id_mini); return ans; }else{ // mini ta a esquerda // maxi ta dentro ou a esquerda assert(maxi <= u); ans.push_back(id_maxi); if(maxi >= l){ // maxi ta dentro return ans; }else{ // maxi ta a esquerda l -= maxi; u -= maxi; } W.pop_back(); } } if(0 >= l && 0 <= u) return ans; else return {}; } int32_t main(){ auto ret = find_subset(15, 17, {6,8,8,7}); for(auto x : ret) cout << x << " "; cout << "\n"; ret = find_subset(14, 15, {5, 5, 6, 6}); for(auto x : ret) cout << x << " "; cout << "\n"; ret = find_subset(10, 20, {15, 17, 16, 18}); for(auto x : ret) cout << x << " "; cout << "\n"; }

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

/usr/bin/ld: /tmp/ccVpHpbW.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccAGMXUX.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status