Submission #1001843

#TimeUsernameProblemLanguageResultExecution timeMemory
1001843ayankarimovaDetecting Molecules (IOI16_molecules)C++14
0 / 100
287 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(auto j:mp1[i.first]){ ans.push_back(j); if(ans.size()==num) break; } //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 && i.second*i.first+num1*(i.first+1)>=l){ 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 && i.second*i.first+num1*(i.first+1)>=l){ 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:18:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   18 |                 if(ans.size()==num) break;
      |                    ~~~~~~~~~~^~~~~
molecules.cpp:30:38: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   30 |                         if(ans.size()==i.second) break;
      |                            ~~~~~~~~~~^~~~~~~~~~
molecules.cpp:34:38: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   34 |                         if(ans.size()==i.second+num1) break;
      |                            ~~~~~~~~~~^~~~~~~~~~~~~~~
molecules.cpp:47:38: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   47 |                         if(ans.size()==i.second) break;
      |                            ~~~~~~~~~~^~~~~~~~~~
molecules.cpp:51:38: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   51 |                         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...