Submission #714495

#TimeUsernameProblemLanguageResultExecution timeMemory
714495europiumDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <numeric> #include <cmath> #include<iterator> #include <set> #include <map> #include <math.h> #include <iomanip> #include <unordered_set> #include <queue> #include <climits> #include "molecules.h" using namespace std; using ll = long long; vector<ll> ps; ll sum(ll l, ll r){ return ps[r + 1] - ps[l]; } vector<int> find_subset(int a, int b, vector<int> w) { ll n = w.size(); ps.resize(n + 1); vector<pair<ll,ll>> pos(n); for (ll i = 0; i < n; i++){ pos[i].first = w[i]; pos[i].second = i; } sort(pos.begin(), pos.end()); // init ps for (ll i = 0; i < n; i++){ ps[i + 1] = ps[i] + pos[i].first; } for (ll k = 0; k < n; k++){ ll l = 0, r = n - k - 1, mid, wsum; // mid = l + (r - l + 1) / 2; // wsum = sum(mid, mid + k); // // if (a <= wsum && wsum <= b){ // vector<ll> ans; // for (ll j = mid; j <= mid + k; j++) ans.push_back(pos[j].second); // return ans; // } while (l <= r) { mid = l + (r - l) / 2; // cout << "BLR " << l << ' ' << r << '\n'; // cout << mid << '\n'; wsum = sum(mid, mid + k); // cout << k << ' ' << wsum << '\n'; if (wsum < a) l = mid + 1; else if (wsum > b) r = mid - 1; else { vector<ll> ans; for (ll j = mid; j <= mid + k; j++) ans.push_back(pos[j].second); return ans; } // cout << "ALR " << l << ' ' << r << '\n'; } } return vector<int>(0); }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:69:24: error: could not convert 'ans' from 'vector<long long int>' to 'vector<int>'
   69 |                 return ans;
      |                        ^~~
      |                        |
      |                        vector<long long int>