Submission #1001806

#TimeUsernameProblemLanguageResultExecution timeMemory
1001806rahidilbayramliDetecting Molecules (IOI16_molecules)C++17
69 / 100
122 ms14436 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; vi find_subset(int l, int u, vi w) { vi ans; vector<pii>vect; for(ll i = 0; i < w.size(); i++) vect.pb({w[i], i}); sort(all(vect)); set<ll>st; int tl = 0, tr = 0; ll sum = 0; while(tl < vect.size()) { while(tr < vect.size() && sum + vect[tr].f <= u) { st.insert(vect[tr].s); sum += (ll)(vect[tr].f); if(l <= sum && sum <= u) { for(auto u : st) ans.pb(u); return ans; } tr++; } if(l <= sum && sum <= u) { for(auto u : st) ans.pb(u); return ans; } sum -= vect[tl].f; st.erase(vect[tl].s); if(l <= sum && sum <= u) { for(auto u : st) ans.pb(u); return ans; } tl++; } if(l <= sum && sum <= u) { for(auto u : st) ans.pb(u); } return ans; }

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:26: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]
   26 |     while(tl < vect.size())
      |           ~~~^~~~~~~~~~~~~
molecules.cpp:28: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]
   28 |         while(tr < vect.size() && sum + vect[tr].f <= u)
      |               ~~~^~~~~~~~~~~~~
#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...