Submission #552476

#TimeUsernameProblemLanguageResultExecution timeMemory
552476SharkyDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() #define mp make_pair #define pb push_back #define fi first #define se second #define endl "\n" #define vll vector<long long> const int inf = 1e9 + 5; const int MOD = 1e9 + 7; #define FOR(i, a, b) for (int i=a; i<(b); i++) #define F0R(i, a) for (int i=0; i<(a); i++) bool cmp(pair<ll, ll> x, pair<ll, ll> y) { return x.fi < y.fi; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll n, lo, hi; cin >> n >> lo >> hi; vector<pair<ll, ll> > v(n); vll psum(n); F0R(i, n) { cin >> v[i].fi; v[i].se = i; } sort(all(v), cmp); F0R(i, n) { if (i == 0) { psum[0] = v[0].fi; } else { psum[i] = psum[i - 1] + v[i].fi; } } if (psum[n - 1] >= lo && psum[n - 1] <= hi) { cout << n << endl; for (ll i = 0; i < n; i++) { cout << i << " "; } cout << endl; return 0; } for (ll i = 1; i < n; i++) { if (psum[n - 1] - psum[i - 1] >= lo && psum[n - 1] - psum[i - 1] <= hi) { cout << n - i << endl; for (ll j = i; j <= n - 1; j++) { cout << v[j].se << " "; } cout << endl; return 0; } } /*for (ll i = 0; i < n; i++) { cout << psum[i] << " "; } cout << endl; */ for (ll i = 0; i < n; i++) { ll ans = -1; ll l = 0, r = n - 1; ll mid = (l + r) / 2; if (i == 0) { //ll l = 0, r = n - 1; ll mid = (l + r) / 2; while (l < r) { mid = (l + r) / 2; if (psum[mid] < lo) l = mid + 1; else if (psum[mid] >= lo && psum[mid] <= hi) { ans = mid; break; } else { r = mid; } ans = mid; } } else { //ll l = 0, r = n - 1; ll mid = (l + r) / 2; while (l < r) { mid = (l + r) / 2; if ((psum[mid] - psum[i - 1]) < lo) l = mid + 1; else if (psum[mid] - psum[i - 1] >= lo && (psum[mid] - psum[i - 1]) <= hi) { ans = mid; break; } else r = mid; // ansl = l; ansr = r; ans = mid; } } if (ans == -1) { continue; } else { //cout << i << endl; if (i == 0) { if (psum[ans] >= lo && psum[ans] <= hi) { cout << ans + 1 << endl; for (ll j = 0; j <= ans; j++) { cout << v[j].se << " "; } cout << endl; return 0; } } else { if (psum[ans] - psum[i - 1] >= lo && psum[ans] - psum[i - 1] <= hi) { cout << ans - i + 1 << endl; for (ll j = i; j <= ans; j++) { cout << v[j].se << " "; } cout << endl; return 0; } } } } cout << 0 << endl; return 0; }

Compilation message (stderr)

/usr/bin/ld: /tmp/cci1UIFW.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccSTI0cX.o:molecules.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cci1UIFW.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