Submission #987011

#TimeUsernameProblemLanguageResultExecution timeMemory
987011woodDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms348 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> p32; typedef pair<ll,ll> p64; #define pb push_back #define eb emplace_back #define fi first #define se second #define vi vector<int> #define vp32 vector<p32> #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) #define MOD %1000000007 #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //never guess //never debug without reviewing code //never try adding ones or substracting them //only step by step debug when necessay std::vector<int> find_subset(int l, int u, std::vector<int> W) { vector<p64> w; ll totalsum = 0; for(int i = 0; i<W.size(); i++){ w.eb(W[i],i); totalsum+=W[i];} sort(w.begin(),w.end()); ll sum = 0; if(w[0].fi>u||totalsum<l) return{}; deque<int> res; int i; for(i = 0; i<w.size()&&sum+w[i].fi<u; i++){ sum+=w[i].fi; res.pb(w[i].se); } while(i<w.size()&&sum<u){ sum+=w[i].fi; res.pb(w[i].se); if(sum>u){ sum-=w[i-res.size()].fi; res.pop_front(); } i++; } return vi(res.begin(),res.end()); } // int main(int argc, char const *argv[]) // { // for(int x : find_subset(3,3,{1,1,1})) cout<<x<<' '; // return 0; // }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:30:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i = 0; i<W.size(); i++){ w.eb(W[i],i); totalsum+=W[i];}
      |                    ~^~~~~~~~~
molecules.cpp:36:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(i = 0; i<w.size()&&sum+w[i].fi<u; i++){
      |                ~^~~~~~~~~
molecules.cpp:40:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     while(i<w.size()&&sum<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...