Submission #1002024

#TimeUsernameProblemLanguageResultExecution timeMemory
1002024rahidilbayramliDetecting Molecules (IOI16_molecules)C++17
69 / 100
33 ms5584 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); vl ans; vector<pll>vect; for(ll i = 0; i < w.size(); i++) vect.pb({w[i], i}); sort(all(vect)); ll tl = 0, tr = 0; ll sum = 0; while(tl < vect.size()) { while(tr < vect.size() && sum + vect[tr].f <= u) { sum += vect[tr].f; tr++; } if(l <= sum && sum <= u) { for(ll j = tl; j < tr; j++) ans.pb(vect[j].s); return ans; } sum -= vect[tl].f; tl++; } if(l <= sum && sum <= u) { for(ll j = tl; j < tr; 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:22:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(ll i = 0; i < w.size(); i++)
      |                   ~~^~~~~~~~~~
molecules.cpp:27: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]
   27 |     while(tl < vect.size())
      |           ~~~^~~~~~~~~~~~~
molecules.cpp:29: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]
   29 |         while(tr < vect.size() && sum + vect[tr].f <= u)
      |               ~~~^~~~~~~~~~~~~
molecules.cpp:12:11: warning: unused variable 'first' [-Wunused-variable]
   12 | #define f first
      |           ^~~~~
molecules.cpp:18:8: note: in expansion of macro 'f'
   18 |     ll f = min(l, u);
      |        ^
molecules.cpp:19:8: warning: unused variable 'g' [-Wunused-variable]
   19 |     ll g = max(l, 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...