Submission #1002057

#TimeUsernameProblemLanguageResultExecution timeMemory
1002057rahidilbayramliDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms856 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) { ll f = min(l, u); ll g = max(l, u); l = f, u = g; vl ans; vector<pll>vect; vect.pb({0, 0}); for(ll i = 0; i < w.size(); i++) vect.pb({w[i], i}); ll n = w.size(), i; ll pref[n+5]; pref[0] = 0; for(i = 1; i <= n; i++) pref[i] = pref[i-1] + vect[i].f; sort(all(vect)); for(i = 1; i <= n; i++) { ll lo = i, hi = n; while(lo <= hi) { ll mid = (lo + hi) / 2; if(pref[mid] - pref[i-1] < l) lo = mid + 1; else if(pref[mid] - pref[i-1] > u) hi = mid - 1; else { for(ll j = i; j <= mid; j++) ans.pb(vect[j].s); return ans; } } } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:24:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(ll i = 0; i < w.size(); i++)
      |                   ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...