Submission #101303

#TimeUsernameProblemLanguageResultExecution timeMemory
101303chunghanDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> //#include"molecules.h" using namespace std; typedef long long int lld; typedef pair<int, int> pii; vector<int> find_subset(int l, int u, vector<int> w) { vector<pii> p; vector<int> rst; int a = 0, b = 0; lld sum = 0; for (int i = 0; i < (int)w.size(); i++) p.push_back({w[i], i}); sort(p.begin(), p.end()); while (b < w.size() && sum < l) { //cout << 'a'; sum += p[b++].first; if (l <= sum && sum <= u) break; while (a <= b && sum > u) sum -= p[a++].first; } //cout << sum << endl; if (l <= sum && sum <= u) for (int i = a; i < b; i++) rst.push_back(p[i].second); return rst; } int main() { vector<int> w; w.push_back(6); w.push_back(8); w.push_back(8); w.push_back(7); vector<int> r = find_subset(15, 17, w); for (int i = 0; i < r.size(); i++) cout << r[i] << ' '; return 0; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:17:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while (b < w.size() && sum < l) {
            ~~^~~~~~~~~~
molecules.cpp: In function 'int main()':
molecules.cpp:38:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < r.size(); i++) cout << r[i] << ' ';
                     ~~^~~~~~~~~~
/tmp/ccqzNm18.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccuiLioV.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status