Submission #1001735

#TimeUsernameProblemLanguageResultExecution timeMemory
1001735vjudge1Detecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include "molecules.h" #include<bits/stdc++.h> #pragma GCC optimize("-O3") #define ll int #define ld long double #define vl vector<ll> #define vi vector<int> #define pii pair<int, int> #define pll pair<ll, ll> #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define f first #define s second #define pb push_back #define p_b pop_back using namespace std; vl find_subset(ll l, ll u, vl w) { vl ans; vector<pll>vect; for(ll i = 0; i < w.size(); i++) vect.pb({w[i], i}); sort(all(vect)); ll tl = 0, tr = 0, sum = 0; while(tl < vect.size()) { while(tr < vect.size() && sum + vect[tr].f <= u) { sum += vect[tr].f; tr++; if(l <= sum && sum <= u) { for(ll j = tl; j < tr; j++) ans.pb(vect[j].s); return ans; } } if(l <= sum && sum <= u) { for(ll j = tl; j < tr; j++) ans.pb(vect[j].s); return ans; } sum -= vect[tl].f; tl++; } return ans; } int main() { int n, l, u; vi w; cin >> n >> l >> u; for(int i = 0; i < n; i++) { int x; cin >> x; w.pb(x); } vi res = find_subset(l, u, w); for(auto u : res) cout << u << ' '; cout << "\n"; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:20:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(ll i = 0; i < w.size(); i++)
      |                   ~~^~~~~~~~~~
molecules.cpp:24:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     while(tl < vect.size())
      |           ~~~^~~~~~~~~~~~~
molecules.cpp:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         while(tr < vect.size() && sum + vect[tr].f <= u)
      |               ~~~^~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccuyue7c.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccLYrin9.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status