Submission #1085009

#TimeUsernameProblemLanguageResultExecution timeMemory
1085009nickolasarapidisDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
//#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w){ int N = w.size(); vector<pair<int, int>> W(N); for(int i = 0; i < N; i++){ W[i] = make_pair(w[i], i); } vector<int> ans; int sum = 0; for(int i = 0; i < N; i++){ sum += W[i].first; } if(sum >= l and sum <= u){ for(int i = 0; i < N; i++){ ans.push_back(i); } return ans; } if(sum < l){ return ans; } sort(W.begin(), W.end()); bool found = false; set<int> s; sum = 0; for(int i = 0; i < N; i++){ sum += W[i].first; ans.push_back(W[i].second); if(sum >= l and sum <= u){ found = true; break; } } if(found == false) return {}; /*for(int i = 0; i < N; i++){ if(s.count(W[i].second) == 0){ ans.push_back(W[i].second); } }*/ return ans; } int main(){ vector<int> A = find_subset(10, 20, {15, 16, 17, 18}); for(int i = 0; i < A.size(); i++){ cout << A[i] << " "; } }

Compilation message (stderr)

molecules.cpp: In function 'int main()':
molecules.cpp:65:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     for(int i = 0; i < A.size(); i++){
      |                    ~~^~~~~~~~~~
/usr/bin/ld: /tmp/cchbcoyu.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccZz84lq.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status