Submission #961710

#TimeUsernameProblemLanguageResultExecution timeMemory
961710ErJDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define vi vector<ll> #define pp pair<ll, ll> #define inf 1000000000000000; #define vvi vector<vi> #define vp vector<pp> #define rep(i, n) for(int i = 0; i < n; i++) #define mod 1000000007 vector<int> result; vector<int> find_subset(ll l, ll r, vector<ll> w) { sort(w.begin(), w.end()); ll n = w.size(); vi pref(n), suff(n); pref[0] = w[0]; suff[0] = w[n - 1]; rep(i, n - 1) { pref[i + 1] = pref[i] + w[i + 1]; suff[i + 1] = suff[i] + w[n - i - 2]; } set<ll> ans; result.clear(); rep(i, n) { ans.insert(i); if (pref[i] <= r && suff[i] >= l) { result.clear(); ll akt = pref[i]; if (pref[i] >= l) { auto it = ans.begin(); for (ll j = 0; j < ans.size(); j++) { result.push_back(*it); it++; } } else { for (int j = i; j >= 0; j--) { akt -= w[j]; ans.erase(j); ll left = i; ll right = n - (i - j); ll hledam = r - akt; while (right > left + 1) { ll mid = (right + left) / 2; if (w[mid] > hledam) { right = mid; } else { left = mid; } } akt += w[left]; ans.insert(left); if (l <= akt && akt <= r) { auto it = ans.begin(); for (ll j = 0; j < ans.size(); j++) { result.push_back(*it); it++; } } } } break; } } return result; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(long long int, long long int, std::vector<long long int>)':
molecules.cpp:33:34: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::set<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |                 for (ll j = 0; j < ans.size(); j++) {
      |                                ~~^~~~~~~~~~~~
molecules.cpp:58:42: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::set<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |                         for (ll j = 0; j < ans.size(); j++) {
      |                                        ~~^~~~~~~~~~~~
/usr/bin/ld: /tmp/ccJlvec3.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