Submission #1001835

#TimeUsernameProblemLanguageResultExecution timeMemory
1001835ayankarimovaDetecting Molecules (IOI16_molecules)C++14
0 / 100
296 ms65536 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define ll long long std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<int>ans; map<ll, ll>mp; map<ll, vector<ll>>mp1; for(int i=0; i<w.size(); i++){ mp[w[i]]++; mp1[w[i]].push_back(i); } for(auto i:mp){ ll num=(l+i.first-1)/i.first; if(num<=i.second && num*i.first<=u){ for(int j=1; j<=num; j++){ ans.push_back(i.first); } //cout<<1<<endl; return ans; } if(mp[i.first+1]){ ll cur=l-i.second*i.first; ll num1=(cur+(i.first+1)-1)/(i.first+1); if(num1<=mp[i.first+1] && i.second*i.first+num1*(i.first+1)<=u){ for(auto j:mp1[i.first]){ ans.push_back(j); if(ans.size()==i.second) break; } for(auto j:mp1[i.first+1]){ ans.push_back(j); if(ans.size()==i.second+num1) break; } //cout<<2<<endl; sort(ans.begin(), ans.end()); return ans; } } if(mp[i.first-1]){ ll cur=l-i.second*i.first; ll num1=(cur+(i.first-1)-1)/(i.first-1); if(num1<=mp[i.first-1] && i.second*i.first+num1*(i.first-1)<=u){ for(auto j:mp1[i.first]){ ans.push_back(j); if(ans.size()==i.second) break; } for(auto j:mp1[i.first-1]){ ans.push_back(j); if(ans.size()==i.second+num1) break; } //cout<<2<<endl; sort(ans.begin(), ans.end()); return ans; } }} return ans; } /* {} [] 7 13 14 2 2 3 3 3 4 4 */

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i=0; i<w.size(); i++){
      |                  ~^~~~~~~~~
molecules.cpp:28:38: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   28 |                         if(ans.size()==i.second) break;
      |                            ~~~~~~~~~~^~~~~~~~~~
molecules.cpp:32:38: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   32 |                         if(ans.size()==i.second+num1) break;
      |                            ~~~~~~~~~~^~~~~~~~~~~~~~~
molecules.cpp:45:38: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   45 |                         if(ans.size()==i.second) break;
      |                            ~~~~~~~~~~^~~~~~~~~~
molecules.cpp:49:38: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   49 |                         if(ans.size()==i.second+num1) break;
      |                            ~~~~~~~~~~^~~~~~~~~~~~~~~
#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...